# Power in C Programming | C Pow() Function

Power in c uses pow() function to calculate power of a number, which must use “#include<math.h>”, given by the user.

## What is Power function in c

The pow() function determines raised to the power of y,given two numbers and their base and exponent which is “xy” and returns x raised to the power of y. Essentially, the c pow() function is used to determine exponent value and calculate the number’s power, which must use #include<math.h>.

Example – pow(5 , 3); Then we will get the result as 5^3, which is 125.

## Syntax

syntax for C Pow() Function:

``double pow(double x, double y);``

### c pow() Parameters:

Function takes two parameters:

• x – The base value
• y – The power value

## Example of power in c programming:

From this examples learn how to raise to a power in c

### Example 1:

Calculating power of a number in c using while loop

``````#include<stdio.h>
int main()
{
int base, exponent,power, i;

//Reading base & exponent
printf("Enter base: ");
scanf("%d",&base);
printf("Enter exponent: ");
scanf("%d",&exponent);

power = 1;
i = 1;
//caculatinh power of given number
while(i <= exponent)
{
power = power * base;
i++;
}
printf("Power : %d", power);
return 0;
}``````

### Calculating power of a number using for loop

``````#include<stdio.h>
int main()
{
int base, exponent, i, power;

//Reading base & exponent
printf("Enter base: ");
scanf("%d",&base);

printf("Enter exponent: ");
scanf("%d", &exponent);
power = 1;

//caculatinh power of given number using for loop
for(i=1; i<=exponent; i++)
power = power * base;

printf("Power : %d", power);
return 0;
}``````

# Result

TaggedWrite C program to calculate power using while & for loop

### Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

### C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …