Multiplication Table?

So I'm supposed to write something that will output a multiplication table from two user input integers between 2 and 10.

For example it should display like this is the user inputs 4 and 5
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20

I was hinted to used two for loops and this is what I have thus far, what I can't figure out is how to display it like the example. Any help is appreciated.


#include <iostream>

using namespace std;

int main()
{
int num1;
int num2;

cout << "Enter two numbers between 2 and 10." << endl;
cin >> num1;
cin >> num2;
cout << endl << endl;

for (int i = 1; i <= num1; ++i)
{
cout << endl;
for (int j = 1; j <= num2; ++j)
{

}
}
1
2
3
4
5
6
for (int i=1;i <=num1; i++)
{
 cout <<endl;
 for (int j=1; j <=num2; j++)
   cout <<i*j <<" ";
}

Try this out. :)
Hey that worked! Thank you! :)


#include <iostream>

using namespace std;

int main()
{
int num1;
int num2;

cout << "Enter two numbers between 2 and 10." << endl;
cin >> num1;
cin >> num2;
cout << endl << endl;

for (int i = 1; i <= num1; i++)
{
cout << endl;
for (int j = 1; j <= num2; j++)
cout << i*j << " ";
}
cout << endl << endl;
}
Topic archived. No new replies allowed.