Search This Blog

Find the power of two numbers | c programming

Find the power of two numbers

 

Problem 

Read two values, Find the power of the two numbers.

Input

Input two values n and x.


Output

Print the power of the two values.





Solution

In case of 23
  • 2 is the base number
  • 3 is the exponent
  • And, the power is equal to 2*2*2 
In c programming we use pow() function. Such as, pow(2,3) means 23



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

int main()
{
    double n,x,result;
    scanf("%lf %lf",&n,&x);

    result = pow(n,x);
    printf("%lf\n",result);

    return 0;
}


No comments

Powered by Blogger.