CODE
#include <iostream>
using namespace std;
int main()
{
int row, col, stop;
cout << "Enter a number between -9 and 9, excluding 0: ";
cin >> stop;
while ((stop < -9) || (stop > 9) || (stop == 0))
{
cout << "ERROR: Enter a number between -9 and 9, excluding 0: ";
cin >> stop;
}
cout << " ";
for (int count = 1; count <= stop; count++)
{
cout << count << " ";
}
cout << endl <<" ";
for (count = 1; count <= stop; count++)
{
cout << "---";
}
cout << endl;
for (row = 1; row <= stop; row++)
{
cout << row << " | ";
for (col = 1; col <= stop; col++)
cout << (((row*col) < 10)?" ":"")
<< row*col << " ";
cout << endl;
}
return 0;
}
my problem is that when i put in positive 1-9 it lines up correctly and works, now we have to implement in neg numbers from -1 to -9 and i cant seem to get it to work. I have changed my for loops a thousand times and i think i am going the wrong way. can anyone point me in the right direction, when i put in aneg number it does nothing
i would really aprreciate the help.
I am trying to get this to print out the multiplication table as long as the entered in number is between -9 and 9, excluding zeros. It is suppose to be lined up like it is when i run the positive number on this code. It wont accept a neg number, when i put in the number and press enter, it says "press any key to continue"
This post has been edited by jayman9: 20 Mar, 2007 - 11:29 AM