0

I have another assignment for class that I am having some difficulties with. I seem to be able to write the program, except for the fact that it keeps looping over and over and I'm not quite sure how to stop this. Could anyone please help?? Thanks!

This is the assignment:

Write a program that asks the user for two integers; call

them num1 and num2. Make sure the number is between 1 and 9

(including 1 and 9). For each pair of numbers, print the

division of those two numbers. Note that this is integer

division, so there will be no fractional parts.

See the examples below.

```
EXAMPLE 1:
Please enter a number between 1 and 9: 3
Please enter another number between 1 and 9: 2
1 0
2 1
3 1
EXPLANATION:
Row 1: The first number is 1/1, the second number is 1/2
Row 2: The first number is 2/1, the second number is 2/2
Row 3: The first number is 3/1, the second number is 3/2
EXAMPLE 2:
Please enter a number between 1 and 9: 9
Please enter another number between 1 and 9: 9
1 0 0 0 0 0 0 0 0
2 1 0 0 0 0 0 0 0
3 1 1 0 0 0 0 0 0
4 2 1 1 0 0 0 0 0
5 2 1 1 1 0 0 0 0
6 3 2 1 1 1 0 0 0
7 3 2 1 1 1 1 0 0
8 4 2 2 1 1 1 1 0
9 4 3 2 1 1 1 1 1
Press any key to continue . . .
EXAMPLE 3:
Please enter a number between 1 and 9: 10
That number is out of range.
Press any key to continue . . .
```

Here's what I have so far:

```
#include <iostream>
#include <string>
using namespace std;
int main()
{
int num1, num2;
cout << "Please enter a number between 1 and 9: ";
cin >> num1;
cout << "Please enter another number between 1 and 9: ";
cin >> num2;
if ((num1 <= 1) && (num1 >=9) || (num2 <= 1) && (num2 >= 9))
{
cout << "That number is out of range!" << endl;
}
else
{
while ((num1 >= 1) && (num1 <= 9) || (num2 >= 1) && (num2 <= 9))
{
for (int num3 = 1; num1 <= num1; num3++)
{
for (int num4 = 1; num4 <= num2; num4++)
{
cout << num3/num4 << '\t';
}
cout << endl;
}
}
}
}
```

*Edited 3 Years Ago by pyTony*: fixed formatting