//This program calculates the power of 2 numbers using for loop.
Program
Output
Program
#include<stdio.h>
void main()
{
int a,b,i,pow;
printf("Enter value of a: ");
scanf("%d",&a);
printf("Enter value of b: ");
scanf("%d",&b);
pow=1;
for(i=1;i<=b;i++)
{
pow=pow*a;
}
printf("a^b = %d",pow);
}
Output
Enter value of a: 2
Enter value of b: 5
a^b = 32
No comments:
Post a Comment