POW in C Programming

The C POW function used to calculate the Power of a specified value. For example, if x is base value and 2 is exponent then, pow (x, 2) = x². The syntax of the POW in C Programming is

double pow(double base, double Exponent);
  • Please specify the base value and Exponent Exponent value or power here.

POW in C programming Example

The POW function in c used to return the Power of the given number. In this program, We are going to find the power of both positive and negative values, and display the output using the pow in C Programming and the printf statement

#include <stdio.h>
#include <math.h>

int main()
{
  int result1; 
  double result2, result3, result4, result5;
   
  result1 = pow(5, 3);
  printf("\n The Final result of %d Power %d = %d ", 5, 3, result1);
  
  result2 = pow(2, 0);
  printf("\n The Final result of %d Power %d = %f ", 2, 0, result2);
  
  result3 = pow(0, 2);
  printf("\n The Final result of %d Power %d = %f ", 0, 2, result3);
  
  result4 = pow(-2, 3);
  printf("\n The Final result of %d Power %d = %f ", -2, 3, result4);
  
  result5 = pow(3, -4);
  printf("\n The Final result of %d Power %d = %f ", 3, -4, result5);
  
  return 0;
}
POW in C programming 1

POW Function in C programming Example 2

This program asks the user to enter his/her own base and exponent values. And then it will calculate the power of user-specified values

#include <stdio.h>
#include <math.h>

int main()
{
  int result, base, exponent;
  
  printf("\n Please Enter the Base and Exponent Values : \n ");
  scanf("%d %d", &base, &exponent);
  
  result = pow(base, exponent);
  
  printf("\n The Final result of %d Power %d = %d ", base, exponent, result);
  
  return 0;
}
 Please Enter the Base and Exponent Values :  
 2
 5

 The Final result of 2 Power 5 = 32