C Program to Calculate the Power of a Number
Here is a C program to calculate the power of a number
#include
int main() {
// Declare variables
int base, exponent, result;
// Get input from user
printf("Enter base: ");
scanf("%d", &base);
printf("Enter exponent: ");
scanf("%d", &exponent);
// Calculate power
result = 1;
for (int i = 0; i < exponent; i++) {
result *= base;
}
// Print result
printf("%d to the power of %d is %d\n", base, exponent, result);
return 0;
}
Output

This program first declares three variables:
base
,exponent
, andresult
. Thebase
variable stores the base number, theexponent
variable stores the exponent, and theresult
variable stores the result of the calculation.The program then gets input from the user for the base number and the exponent.
The program then calculates the power using a for loop. The for loop iterates
exponent
times, and each time it multipliesresult
bybase
.The program then prints the result to the console.
You can change the values of the variables in the program to calculate the power of different numbers.
SELECT AVG(emp_sal)
FROM employee;
SELECT COUNT(*)
FROM employee;