What to Code This?

Hey need help for creating Do While Loop code for Cin Base and Cin Power

Base = 5
power = 3

5 x 5 x 5 x 5 x 5
not understood this.
wrong example. not clear.
1
2
3
4
5
6
7
8
9
10
int base=5;
int power=3;
int result=1;
int i=0;

do{
result=result*base;
i++;
}while(i<power)
Last edited on


Please help to fix this


#include <iostream>

using namespace std;

int main()

{
int a, b , c;
int d=1;
char e;
do
{
cout<<"enter base : ";
cin>>a;
cout<<"enter power : ";
cin>>b;
for (c=1;c<=b;c++)
{
d=d*a;
cout<<"the answer ="<<d;
}

}
cout<<"Enter n to exit or others to continue";
cin>>e;
while(e!='n')
}
Last edited on
Topic archived. No new replies allowed.