pow()


The pow function returns x raised to the power of y. If x is negative and y is not an integer value, the pow function will return a domain error.

Sample Program:

/*
Write a program to illustrate pow math function of C.
*/

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

main()
{
 double a, b, result;
 printf("Enter a and b to calculate a^b ");
 scanf("%lf%lf",&a, &b);
 result = pow(a, b);
 printf("%lf raised to %lf = %lf", a, b, result);
 return 0;
}

Output:
Enter a and b to calculate a^b 1.2 1.2
1.2 raised to 1.2 = 1.24

Post a Comment

0 Comments