Write a C Program to calculate the power of a number, given the number and the exponent.
CODE:
#include<stdio.h>
main ()
{
int num=0,expo=0,i=0,sum=0;
printf("enter num:");
scanf("%d",&num);
printf("enter power:");
scanf("%d",&expo);
i=num;
do{
num=num*i;
expo--;
}while(expo!=1);
printf("ans is:%d",num);
return 0;
}
Program Output:
For more problems click here
No comments:
Post a Comment