Range 1-20 Table that shows divisibility

I have to write a C++ program that
1.Requests a positive number “N” from the user that is in the range [1, 20]. If the user enters a number outside this range, display an error message and request the number again.

2. Using a nested loop, display a table similar to the one below (the example is for the case N=20). Each of the table entries indicates with ‘y’ that the corresponding column can divide exactly the corresponding row. Otherwise, ‘n’.


My professor said to write an "if-else statement" and a "modulus statement" to show its divisibility.

Here is what I have so far:
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
33
34
#include "stdafx.h"



#include <iostream>

using namespace std;

int main()
{
	
	int sideLen;

	cout << "Please enter number or rows/columns: ";


	do {
		cin >> sideLen;
		if (sideLen<1 || sideLen>20)
			cout << "Error, please re-enter\n";
	} while (sideLen<1 || sideLen>20);
	

	for (int i = 0; i <= sideLen; i++) {

		for(int j=0; j<=sideLen; j++) {     // this one makes a square

		
			cout << '#';
		}
		cout << endl;
	}
	system("pause");
}
Topic archived. No new replies allowed.