Hello, I had to creat the following code that displays a table depending on the number te user entered.
int main()
{
int n = 0;
const int base = 4;
std::cout << "Enter max: ";
std::cin >> n;
std::cout << " ";
for(int i = 1; i<= n; ++i)
std::cout << std::setw(base) <<i;
std::cout << "\n " << std::string(n * base, '-') << "\n";
for(int i = 1; i <= n; ++i)
{
for(int j = 1; j <= n; ++j)
{
if(j == 1)
std::cout <<std::setw(2) << i << '|';
std::cout << std::setw(base) << i * j;
}
std::cout<<"\n";
}
It works so far. I also need to display a message when the user enters a number less than zero or a number above my
multidimensional array.
if( n < 0 )
cout<<" hey dummy, can't be negative, trry again";
else if( n > maxN )
cout<< " hey stupid, don't you know nothing, try again;
How to I define " number above my multidimensional array" ? n > what ? Gotta define maxN somehow, but I don't know how...