Calculate Power of a Number using pow(): C Program

Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another by using pow() method present in math.h library.

Related Read:
while loop in C programming
Calculate Power of a Number: C Program

One Number Raised To Another using pow(): C Program



YouTube Link: https://www.youtube.com/watch?v=i-aop38U0Hg [Watch the Video In Full Screen.]


Source Code:One Number Raised To Another using pow(): C Program

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

int main()
{
    int base, exponent;

    printf("Enter base value\n");
    scanf("%d", &base);

    printf("Enter exponent value\n");
    scanf("%d", &exponent);

    printf("%d to the power of %d is %2f\n",
           base, exponent, pow(base, exponent));

    return 0;
}

Output:
Enter base value
25
Enter exponent value
3
25 to the power of 3 is 15625.000000

Note:
pow() method is present in math.h library, so we include it at the top of our c source code.

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert