sqrt in c: The function double sqrt(double x); returns the square root of x.
Function prototype of sqrt
double sqrt(double x);
- x : A floating point value whose square root to be computed. It must be a positive number.
Return value of sqrt
sqrt function in c: It returns the square root of x. If x is negative, it causes a domain error.
C program using sqrt function
sqrt function c: The following program shows the use of sqrt function to calculate square root of a number.
#include <stdio.h> #include <math.h> int main () { double x, result; printf("Enter a number\n"); scanf("%lf", &x); result = sqrt(x); printf("Square root of %lf = %lf\n", x, result); return 0; }
Output
Enter a number 49 Square root of 49.000000 = 7.000000
Enter a number 85.453 Square root of 85.453000 = 9.244079