+ 1
How do i use squaring cubing power of 4 etc.
title sais it all i did try #include <cmath>...z=x^y; but z will be 0
3 Antworten
+ 5
@Himanshu
It doesn't seems logical at all you must
first input the values and then call the pow function.
0
Hi there!
if you want to find the value of no. x to the power y,then try the following code :-
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int x, y, z;
cin>>x;
cin>>y;
z = pow(x,y);
cout<<z;
return 0;
}
Here pow(x,y) is the function of cmath library used for finding the value of x to the power y.
Happy coding!
0
oops, sorry.
Thanks for the correction. It's alright now