Pages

Sunday, September 4, 2016

Calculate the power of an integer using inbuilt pow function.


/* C program to calculate the power of an integer using inbuilt pow function*/

#include <stdio.h>
#include <math.h>
int main()
{
  int base, exponent;
  long int answer=1;
 
  printf("Enter base number:");
  scanf("%d", &base);
 
  printf("Enter exponent number:");
  scanf("%d", &exponent);
 
  answer = pow(base,exponent); 
 
  printf("Power of %d to the %d = %d", base, exponent, answer);
}



Output of the Program:

Enter base number:5
Enter exponent number:3
Power of 5 to the 3 = 125


No comments:

Post a Comment