I need C++ to use cout to print:
Header
1
2
3
4
5
10
11
12
instead of
Header
1
2
3
4
5
10
11
12
How should I format this using cout?
use the IO manipulator setw
#include <iostream>
#include <iomanip>
int main()
{
std::cout << "Header\n";
for(int i=1; i<13; ++i)
std::cout << std::setw(6) << i << '\n';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With