Friday 3 August 2012

Find Power of A Number in C


#include<stdio.h>
#include<conio.h>
void main()

{
  int pow,num,i=1;
  unsigned  long int sum=1;

  printf("\nEnter your number == ");
  scanf("%d",&num);

  printf("\nEnter the desired power ==");
  scanf("%d",&pow);

  while(i<=pow)
  {
      sum=sum*num;
      i++;
  }

  printf("\n%d to the power %d is: %ld",num,pow,sum);
  getche();
}

No comments:

Post a Comment