How to Format Output in C++ Using setw() and endl()

  • Thread starter Thread starter magnifik
  • Start date Start date
  • Tags Tags
    Format Program
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
1 reply · 2K views
magnifik
Messages
350
Reaction score
0
resovledddddd
 
Last edited:
Physics news on Phys.org
Its a bit hard to see how you intend things to be lined up since your code seems to just prints everything on one line. Perhaps you should include some endl() somewhere? If you are in doubt where, make an example of how you would like the output to be and start figuring out on what "condition" you want a new line.

Also, if you use setw() to format your output you should note, that it sets the with for the next field being output. You can see a short description on [1].[1] http://www.cprogramming.com/tutorial/iomanip.html