write a C++ program which will raise any number x to a positive power n using a for loop?
1
Expert's answer
2013-05-24T07:46:13-0400
#include <iostream> #include <conio.h>
using namespace std; //main function int main() { int x,n,raise=1;//declare variable cout<<"Enter x: "; cin>>x;//read x cout<<"Enter positive power n: "; cin>>n;//read n //raise any number x to a positive power n using a for loop for(int i=0;i<n;i++){ raise*=x; } //show result cout<<x<<"^"<<n<<" = "<<raise; getch(); return 0; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
You're welcome. We are glad to be helpful. If you really liked our service please press like-button beside answer field. Thank you!
i am appriciet your program.
Leave a comment