This blog is under construction

Monday 30 April 2012

sqrt example in C

Header file:
    math.h

Synopsis:
     double sqrt(double x);

Description:
     Returns the square root of x.


sqrt function C example:


  #include<stdio.h> 
  #include<math.h>
  int main() {
        double x, res;
        printf("Enter your input:");
        scanf("%lf", &x);
        res = sqrt(x);
        printf("sqrt(%lf)=%lf\n", x, res);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter your input:25
  sqrt(25.000000)=5.000000

 

No comments:

Post a Comment