- #1
ineedhelpnow
- 651
- 0
Program should compute the power x^2
as you can see, there is no math library included and i need to be able to perform the operation x^n. i figured everything out except the main part which is the loop. do i need to use a do loop?
Code:
#include<iostream>
int main() {
double x;
int n;
double pow=1;
cout<<"Please enter x:";
cin>>x;
cout<<"Please enter n:";
cin>>n;
[B]LOOP FOR X^N[/B]
pow=pow*x
cout<<"The result is: "<<pow<<endl;
return 0;
}
as you can see, there is no math library included and i need to be able to perform the operation x^n. i figured everything out except the main part which is the loop. do i need to use a do loop?