February 4th, 2010, 06:20 PM
Join Date: Dec 2007
Time spent in forums: 1 Week 1 Day 21 h 27 m 36 sec
Reputation Power: 12
Are you deliberately trying to confuse a newbie?
Or are you just a generic complicator
(Or, it might help to read
what they're actually posting.)
for(i = 1; i < 20; i++);
printf ("%8d %8d %8d\n", i, i * i, i * i * i);
Remove the highlighted ;
I would also suggest staying away from printf(), that's something you use in C. In C++ we have better. It probably won't work with only the headers you've included, either.
Replace that printf call with
cout << i << ' ' << i*i << ' ' << i*i*i << '\n';
Programming by Coincidence
Fred types in some more code, tries it, and it still seems to work. [Then] the program suddenly stops working. [...] Fred doesnít know why the code is failing because he didnít know why it worked in the first place.
Undefined behavior results in: (worst to best)
-Erases your harddisk. Really.
-Appears to work - for now