Dec 14, 2011

Program : Using Sqrt Function





Program : Using Sqrt Function

Today we are going to learn about new Built in Function sqrt() can be used using math.h header file. Its mathematical function use to find square root of that number. 



To Understand how to use check following example:-


#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()

{
float a; // float datatype store numeric value with decimal places
cout << "Enter any +ve number \n"; //square root of -ve is not possible
cin >> a; //take value in a variable
cout << "Square Root of Number = " << sqrt(a);
/* sqrt function is used to find square root, for that in brackets of sqrt() we have to write numeric value for what we want to find square root. In this example I define a variable a and I take value from user in 'a' variable & used that value to find square root. So To find that sqrt(a); is use a is value take from user */
getch();
return 0;
}




OUTPUT






0 comments:

Post a Comment