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.
#include "stdafx.h"
#include <iostream>
usingnamespace 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");
}