Don't know where to start..

This is an assignment for my class, and I honestly don't know how to approach it. Anyone have any suggestions? It's not like any other program he's asked us to write:

Print a table of powers that prints x, x squared, x cubed, the square root of x, and the cube root of x with x going from 1 to 10:
Can you do the program for some arbitrary x?
Which part are you stuck with? For example, do you know how to do this:
Print a table that prints x, with x going from 1 to 10.
 ``1234567891011121314151617181920212223242526`` ``````// Jacob Ford // Chapter 5 Exercise 3 #include #include using namespace std; int main(int argc, char** argv) { int x; while(true){ cout << "enter a number between 1 and 10: "; cin >> x; if(x > 10 | x < 1){ cout << "that was not a valid number!\n\n"; continue; } break; } cout << x << " squared = " << pow(x,2) << endl; cout << x << " cubed = " << pow(x,3) << endl; cout << "The square root of " << x << " is: " << sqrt(x) << endl; system("PAUSE"); return 0; }``````

I came up with this, I guess it works.
To turn that into a table, there are two changes needed to the design.

Firstly, the layout of the results, a table would have a row of headings (the text stating what the column represents). Then on a separate line, the values printed out each underneath the corresponding heading.

The finishing touch would be to use a loop, to step through each value of x. printing out the values for that value of x each time.

Topic archived. No new replies allowed.