Saturday 14 July 2012

How to find power of a given number in C program

Find out power of a given number using C program. The full source code of this program is  below:



#include<stdio.h>
int main()
{
  int pow,num,i=1;
  long int sum=1;
  printf("\nEnter a number: ");
  scanf("%d",&num);
  printf("\nEnter power: ");
  scanf("%d",&pow);
  while(i<=pow)
{
            sum=sum*num;
            i++;
 }
  printf("\n%d The Power %d is: %ld",num,pow,sum);
  return 0;
}

0 Responses to “How to find power of a given number in C program”

Post a Comment