pow() function in C++ by R4R Team

pow() function in C language are used to find the power of any number.
-It is define in math.h header file.

Syntax-
pow(a,b);
// it will return the a to the power b.

Example-
pow(2,1) will return 2
pow(2,4) will return 16
pow(2,5) will return 32
pow(2,10) will return 1024
pow(5,0) will return 1
pow(2,0) will return 1
pow(1,1000) will return 1


program:

#include < iostream>
#include< math.h>
using namespace std;
int main()
{
int a,b,ans;
cout<<"Enter first number"<< endl;
cin>>a;
cout<<"Enter second number"<< endl;
cin>>b;
ans=pow(a,b);
cout<<"a to the power b is: "<< ans;
return 0;
}


output-

Enter first number
2
Enter second number
4
a to the power b is: 16

-In this program, we take an input of the two number and pass in pow(a,b) function, so this function return the answer that will store in variable 'c'.
-#include< math.h> are used to import the math library for the pow() function.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!