I am supposed to use a for loop to call a function into main that first asks for a range of 2 numbers, then makes multiplication tables that multiply the first number by 0-12 as well as all the numbers in between the first number and the second number. I cannot figure out how to arrange the for loop so that it will do this. I have my code so far attached, but have no idea where to go from what I have or if I am even headed in the right direction. Any sort of help would be appreciated.
#include <iostream>
#include <iomanip>
usingnamespace std;
void table(int num1, int num2, int multiplier);
int main()
{
int num1, num2, multiplier;
cout << "Enter two numbers for your range of multiplication tables: ";
cin >> num1, num2;
while (num1 > num2)
{
cout << "ERROR, number 1 must be less than number 2." << endl;
cout << "Enter a different second number that's greater than " << num1 << ": " << endl;
cin >> num2;
}
for (multiplier = 0; multiplier <= 12; multiplier++)
{
table(num1, num2, multiplier);
}
for (int difference = num1; num1 <= num2; difference++)
{
int total2 = multiplier * difference;
cout << left << setw(3) << difference << " * " << setw(3) << multiplier << " = " << total2 << endl;
}
return 0;
}
void table(int num1, int num2, int multiplier)
{
int total = multiplier * num1;
cout << left << setw(3) << num1 << " * " << setw(3) << multiplier << " = " << total << endl;
}
I got the for loop to do a multiplication table for the first number I enter, but am confused on how to continue to get multiplication tables for the numbers in between up until my second number...