/* Calculate power using for loop */
#include<stdio.h>
int main()
{
int a, b, i, p;
printf("Enter value of a: ");
scanf("%d",&a);
printf("Enter value of b: ");
scanf("%d",&b);
p=1;
for(i=1;i<=b;i++)
p = p * a;
printf("Power : %d",p);
return 0;
}
Related Post:
Calculate Power using while loop
http://cbasicprogram.blogspot.in/2012/01/calculate-power-using-while-loop.html
#include<stdio.h>
int main()
{
int a, b, i, p;
printf("Enter value of a: ");
scanf("%d",&a);
printf("Enter value of b: ");
scanf("%d",&b);
p=1;
for(i=1;i<=b;i++)
p = p * a;
printf("Power : %d",p);
return 0;
}
Related Post:
Calculate Power using while loop
http://cbasicprogram.blogspot.in/2012/01/calculate-power-using-while-loop.html
No comments:
Post a Comment