Function overlaoding for calculating the square root of the different numbers
# include<iostream.h># include<conio.h>
int sroot(int n)
{
return(sqrt(n));
}
long int sroot(long int n)
{
return(sqrt(n));
}
double sroot(double n)
{
return(sqrt(n));
}
void main()
{
int num;
long int num1;
double num2;
cout << "Enter the value of num ";
cout << "Enter the value of num1";
cout << "Enter the value of num2 ";
cout << "\nSquare root of int is " << sroot(num);
step by step explanation:
1.the header file "iostream.h" is used to include the function cin and cout.2.the header file"math.h" is used to calculate the mathematical function.
3.sqrt is a int type function which is used to calculate the sqrt.
4.main is also a void type function which is worked during the curley brackets.
No comments:
Post a Comment