for (rows=0; rows < 11; rows++)
{
for (cols=0; cols < 11; cols++)
{
sum = rows + cols;
if (sum < 10) cout << " ";
cout << sum << " ";
}
cout << endl;
}
It does generate the addition table correctly. However, for my lab assignment, it cannot display that zero in the top left corner. Is there a way to easily manipulate that?
All variables are defined
for (int rows=0; rows < 11; rows++)
{
for (int cols=0; cols < 11; cols++)
{
sum = rows + cols;
if (sum < 10 )
cout << " ";
if (sum!=0) // If sum isn't 0, then sum and space printed
cout << sum << " ";
else
cout << " "; // otherwise, just a space, to keep everything in line
}
cout << endl;
}