how can I printed the result with 10 numbers per row and with 5-character width for each number?

#include<iostream>
#include<iomanip>
int counter = 0;
for (int n = 2; n <= 200; n++) {
//(1) check if n is prime or not
bool isPrime = true;
for (int k = 2; k <= n / 2; k++) {
if (n%k == 0) {
isPrime = false;
} // end if
} // end inner for

//(2) print n if n is prime
if (isPrime) {
cout << setw(5) << n;

counter++;
} // end if
}// end outer for

cout << endl;
adding
1
2
3
4
			if ((counter % 10) == 0)
			{
				cout << endl;
			}
after counter++;
Topic archived. No new replies allowed.