C Program to calculate the power of any number:This program is calculating the power of any number which is input by user. In which we take any number and its power number and calculate them.
For Example: We input a number which is 2 and power 4. this is calculate like(2*2*2*2)=16
ALGORITHM:-
step 1 : Start
step 2 : Input any number and its power also from user
step 3 : Now Multiply the number until power is not equal to zero
step 4 : Store the result in variable and display
step 5 : Stop
PROGRAM CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int p,n,i=1;
long int sum=1;
printf("\nEnter a number: ");
scanf("%d",&n);
printf("\nEnter power: ");
scanf("%d",&p);
while(i<=p)
{
sum=sum*num;
i++;
}
printf("\n%d to the power %d is: %ld",n,p,sum);
getch();
}
OUTPUT:-
Enter any number: 2
Enter power: 3
2 to the power 3 is: 8
C Program To calculate the power of given number how to calculate the power of any number using c Power calculator
ConversionConversion EmoticonEmoticon