- Write a c program to read a number and find square root using sqrt function.

#### Required Knowledge

We will first take a number as input from user using scanf function then calculate **square root of number** by calling sqrt function of math.h header file.

## C program to find square root of a number

/* * C program to calculate square root of a number * using sqrt function */ #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

**Related Topics**