This blog is under construction

Monday, 30 April 2012

pow example in C

Header file:
    math.h

Synopsis:
     double pow(double x, double y);

Description:
     Returns the value of x to the power of y.


pow function C example:


  #include<stdio.h>
  #include<math.h>
  int main() {
        double x, y, res;
        printf("Enter the value for x and y:");
        scanf("%lf%lf", &x, &y);
        res = pow(x,y);
        printf("x^y<=>pow(x,y):%lf\n", res);
        return 0;
  }



  Output:
  jp@jp-VirtualBox:~/cpgms/math$ gcc pow.c -lm
  jp@jp-VirtualBox:~/cpgms/math$ ./a.out
  Enter the value for x and y:2 4
  x^y<=>pow(x,y):16.000000



No comments:

Post a Comment