Home C Programming Language / Programs / C program to find power of a number using pow function
🚀 Programming Example

C program to find power of a number using pow function

👁 3,409 Views
💻 Practical Program
📘 Step Learning
Learn this program step-by-step with algorithm, source code, output and detailed explanation.

💻 Program Code

/**
 * C program to find power of any number
 */
#include"stdio.h" 
#include "math.h" //Used for pow() function
 
int main()
{
    double x, y, power;
 
    // Reads two numbers from user to calculate power
    printf("Enter base: ");
    scanf("%lf", &x);
    printf("Enter exponent: ");
    scanf("%lf", &y);
 
    // Calculates x^y 
    power = pow(x, y);
 
    printf("x ^ y = %.2lf \n", power);
 
    return 0;
} 
                        

🖥 Program Output

Enter base: 3
Enter exponent: 2
x ^ y = 9.00
Press any key to continue . . .
                            
📚 Learning Subject

Master Programming Through Practical Examples

Improve your coding logic, problem-solving skills and programming confidence by practicing real-world examples with explanations.

🎯 How to learn from this example

First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.

🔥 Practice suggestion

Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.