You are here

sqrt in C

Function sqrt returns the square root of a number.

Declaration: double sqrt(double);

sqrt function in C language

#include <stdio.h>
#include <math.h>

int main()
  double n, result;

  printf("Enter a number to calculate its square root\n");
  scanf("%lf", &n);

  result = sqrt(n);

  printf("Square root of %.2lf = %.2lf\n", n, result);

  return 0;

Output of program:
sqrt math.h C programming

Share this