C++ examples for Function:Math Function
Demonstrate sqrt() function from cmath
#include <iostream> #include <cmath> using namespace std; int main()/*from ww w .jav a 2 s . co m*/ { double number, answer; //sqrt() requires type double cout << "Enter a number: "; cin >> number; //get the number answer = sqrt(number); //find square root cout << "Square root is " << answer << endl; //display it return 0; }