You are here

sqrt function

sqrt function returns square root of a number.

Declaration: double sqrt(double);

C programming code for sqrt

  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6.   double n, result;
  7.  
  8.   printf("Enter a number to calculate it's square root\n");
  9.   scanf("%lf", &n);
  10.  
  11.   result = sqrt(n);
  12.  
  13.   printf("Square root of %.2lf = %.2lf\n", n, result);
  14.  
  15.   return 0;
  16. }

Output of program:
sqrt math.h C programming