Write a program that asks the user to input two numbers x and y. the program calculates x
raise to power y using loop and display the result.
Code
#include<stdio.h>
int main()
{
int x,y,p,i;
printf("Enter two numbers = ");
scanf("%d%d",&x,&y);
p=1;
i=1;
while(i<=y)
{
p=p*x;
i=i+1;
}
printf("Answer= %d\n",p);
system("pause");
return 0;
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.