Friday, 26 July 2013

Chapter 3 solutions problem [B][c]

Question-Two numbers are entered through the keyboard. Write a
program to find the value of one number raised to the power
of another.
Solution-
Another good question. really like this one.

#include<stdio.h>

int main()
{
int a,b,i=1,ans=1;
printf("Enter any number and it's power\n");
scanf("%d",&a,&b);
while(i<=b)
{
ans=ans*a;
i++;
}
printf("Answer=%d\n",ans);
return 0;
}

No comments:

Post a Comment