Thursday, 19 December 2019

Power of a number in C

#include<stdio.h>
#include<conio.h>
int main()
{
int f,i,a,b;
printf("Enter the base: ");
scanf("%d",&a);
printf("Enter the positive exponent: ");
scanf("%d",&b);
f=a;
for(i=2;i<=b;i++)
f=f*a;
printf("The result of %d raised to the power of %d is %d",a,b,f);
return 0;
}

No comments:

Post a Comment

Convey your thoughts to authors.