Saturday, April 6, 2013

sqrt function

sqrt function returns square root of a number.
Declaration :- double sqrt(double);

C programming code for sqrt

#include <stdio.h>
#include <math.h>
 
int main()
{
 
  double n, result;
 
  printf("Enter a number to calculate it's square root\n");
  scanf("%lf", &n);
 
  result = sqrt(n);
 
  printf("Square root of %.2lf = %.2lf\n", n, result);
 
  return 0;
}
Compiler used: 
GCC
AttachmentSize
sqrt.png4.53 KB

No comments:

Post a Comment