Would anyone be able to help me with this assignment. I pretty much almost got it, but I'm still stuck. Here 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
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 is the code I have below. All is does right now is just continues to ask me to enter a number and doesn't do anything else. What do I need to change?
#include <iostream>
#include <string>
using namespace std;
int main()
{
int howmany = 0;
int num1, num2;
do
{
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))
{
for (int num1 = 1; num1 = howmany; num1--)
{
for (int num2 = 1; num2 = howmany; num2--)
{
cout << num1/num2 << '\t';
}
cout << endl;
}
}
else
{
cout << "That number is out of range. " << endl;
break;
}
}
while ((num1 >= 1) && (num1 <=9) || (num2 >=1) && (num2 <= 9));
return (0);
}