I use setw(n) to reserve space: cout << setw(10) << 42; prints 8 spaces followed by 42, right-aligned in a 10-character field. This creates neat columns when printing tables. Unlike precision, width applies only to the next output item.
Writing cout << setw(5) << 10 << 20; prints 10 followed immediately by 20, producing 1020. Use setw() before each value. For left alignment, combine left with setw: cout << left << setw(10) << "Name" << "Age"; prints values aligned to the left edge of their fields.