Using a for loop, write code that will compute the result of an int raised to the power of another int.
For example, your for loop should use two variables, one for the base and one for the exponent.
It should then calculate the base raised to the exponent.
2 raised to the power of 2 should output 4, 2 raised to 8 should output 256, etc.
You would do this by trying to write the code yourself, then posting the code you wrote here between code tags, so we can make an effort to try and help you find your errors..
{
int y = 2;
for (int x = 2; x < 10; x++)
{
cout << x << " raised to the power " << y << endl;
cout << x*y;
y++;
cout << endl;
}
system("PAUSE");
return 0;
}
This seems to compile and work fine, how about if the user would have to input the base variable and the exponent variable?