Printing formatted output

I'm currently trying to print out a histogram of sorts in a format. Here is my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
int main(){
	for (int i = 90; i >= 0; i -= 10){
		cout << setw(10) << i + 1 << " - " << i + 10 << " |" << endl;

	}
My output looks like this
91 – 100 |
81 – 90 |
71 – 80 |
61 – 70 |
51 – 60 |
41 – 50 |
31 – 40 |
21 – 30 |
11 – 20 |
0 – 10 |


Here is the sample output:
  91 – 100  |
  81 – 90   |
  71 – 80   |
  61 – 70   |
  51 – 60   |
  41 – 50   |
  31 – 40   |
  21 – 30   |
  11 – 20   |
  0 – 10    |






Am I doing something wrong with the placement of my setw?
Last edited on
Bump?
Topic archived. No new replies allowed.