Sunday, May 15, 2016

Power of Given Number in C


This sample program will compute the power of a given number in C language. It will ask the user the base and exponents value of the number and then it will compute the power of the given number.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

#include <stdio.h>
#include <stdlib.h>

int main()
{
  int base=0, exponent=0;
  long long int value=1;
  printf("Power of Given Number in C");
  printf("\n\n");
  printf("Give the Base Value     : ");
  scanf("%d",&base);
  printf("Give the Exponent Value : ");
  scanf("%d",&exponent);

  while (exponent != 0)
  {
      value *= base;
      --exponent;
  }
  printf("\n\n");
  printf("The result is %d.", value);
  printf("\n\n");
  printf("\t End of Program");
  printf("\n\n");
  system("pause");
}



No comments:

Post a Comment