How to calculate power of a number using C Program




c programming
c programming
/**********************************************************************
How to Get power of number in c
 **********************************************************************/
#include<stdio.h>
int main(){
  int power, number, i = 1;
  long int sum = 1;

  printf("\nEnter a number : ");
  scanf("%d",&number);
  printf("\nEnter power : ");
  scanf("%d",&power);
  while(i<=power){
      sum = sum * number;
      i++;
    }
  printf("\n%d to the powerer %d is: %ld",number, power, sum);
  return 0;
}



/*

OUTPUT:

Enter a number : 11

Enter power : 2

11 to the powerer 2 is: 121

*/

 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*