C program to find power of a number using pow function

C Programming Language Fundamentals of C Language (Article) Fundamentals of C Language (Program)

3330

Program:

/**
 * 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;
} 

Output:

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

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.