powers.cpp
Demo in class April 3, 2008
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double exponent = 2;
double base, result;
cout << endl <<
endl;
cout << "Let's compute
some powers, please enter a number: ";
cin >> base;
cout << endl <<
endl;
for (double i = 1; i <=
base; i++) {
result = pow(i, exponent);
cout << "The power of " << i << " taken to the power
of " << exponent << " is " << result << endl;
while(i == base && exponent < base) {
exponent++;
i = 0;
cout << endl;
}
}
cout << endl;
return 0;
}