This article is from solution of Let Us C by Yashwant Kanetkar. I also posted many another articles regarding solutions of Let Us C. If you have any problem regarding solution then give comment, I will surely reply your question.
Q. Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.
Ans.
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int num1, num2, i, ans=1;
printf("enter any two numbers ");
scanf("%d%d",&num1,&num2);
// we wanted to find out num1 raised to num2
for(i=1;i<=num2;i++)
{
ans=ans*num1;
}
printf("Answer is %d",ans);
getch();
}