Without a specific question, all I can say is look at the order of your cout statements and your header. They don't match. You may want to get rid of the \n in your header too.
Also, your for loop variable should be an int. You can cast it to a double to call the sqrt function.
Write a program that prints a table of values such as the one below for all numbers starting at 1 and up to and including a number which will be input from the console.
That's not a specific question addressing a problem you're having. Your question should be along the lines of "Here's my code. It's doing x when I want it to do y, and I'm not sure how to make it do z."
Anyway, I gave you a couple of suggestions in my previous post.
GCDEF gave you the hints that you need to make your program right. Also, please format your code. Use 'Go Advanced' then select the code then press '#' It makes the code much easier to read.
When you have \n in a string this causes a new line to be started in the output. So the \n\n after x^2 causes 2 new lines to be output which is probably not what you want. You also want the output in the same order as your heading which is x sqrt(x) x^2 and x^3 but you are outputting in the order x^3 x sqrt(x) x^2. Cout outputs in the order that it is used.
This is the way it should be?... I was also wondering what way I would go about adding a total row along the bottom?
Go back and change your loop to use integers, not doubles.
The reason is that floating point arithmetic is not exact. Right now, you're only getting away with it because you're adding 1 to the value. If you were adding 0.1 or some other fractional element, the loop will execute an indefinite number of times due to floating point rounding errors.
Bookmarks