C program to find the power ‘n’ of the given number ‘a’

C program to find the power ‘n’ of the given number ‘a’ : In this program we will find the power n of the given number.

Code for C program to find the power ‘n’ of the given number ‘a’

#include <stdio.h>
#include <conio.h>
int main()
{
  int base, exponent;
  long value = 1;
  printf("Enter a base value:");
  scanf("%d", &base);
  printf("Enter an exponent value: ");
  scanf("%d", &exponent);
  while (exponent != 0)
  {
    value *= base;
    --exponent;
  }
  printf("result = %ld", value);
  return 0;
}

Output

Enter a base value:2
Enter an exponent value: 4
result = 16

Read: C program to compute sin(x) using Taylor’s series


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment