Calculate x raised to the power of y
C program to find the value of one number raised to the power of another.
Program
#include<stdio.h>
#include<conio.h>
void main()
{
int x, y, i, pow = 1;
printf("Enter the first number(x)\t:");
scanf("%d",&x);
printf("Enter the second number(y)\t:");
scanf("%d",&y);
for(i=1;i<=y;i++)
{
pow = pow * x;
}
printf("%d raised to the power of %d is %d",x,y,pow);
getch();
}
Output
Enter the first number(x) :5
Enter the second number(y) :4
5 raised to the power of 4 is 625