Stream Manipulators


Write a statement that reads 5 successive integers into these variables that have already been declared: x1 x2 x3 x4 x5 . Then write a statement that prints each out on its own line so that they form a right-justified column with a 5-digit width. If any of the integers are 5-digits in size, then they will start at the very beginning of their lines. For example:

|54213
| 8713
|   23
|  147
|   15


For this, I'm wondering whether or not I would have to do an "if-else" statement for the formatting inside a "for-loop" (in addition to setw()-- which I do not completely understand even though I read documentations on it). Does this make sense?
You will not need an if-else, and you could also do it without a loop.

If your going to ask for the input, a start would be (for the first variable)

cin >> x1;
Topic archived. No new replies allowed.