Hi so I'm asked to make a multiplication table with a 2D array and then I have to make it to where the user would input the 2 numbers they would like to multiply from 0-9.So I was thinking of doing it like this and then its required for me to include the setw() to format it. After they enter there numbers and example would look like this.
#include <iostream>
#include <iomanip>
usingnamespace std;
int table(int i,int j)
{
cout << "please enter a number from 0-9 then press enter";
cin >> i;
cout << "enter second number from 0-9";
cin >> j;
return i, j;
}
int main()
{
int table[10][10];
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
table[i][j] = i * j;
}
}
{
for (int i = 0; i <= 9; i++)
{
for (int j = 0; j <= 9; j++)
{
table[i][j] << '\n';
}
}
return 0;
}
}
#include<iostream>
usingnamespace std;
int main()
{
int t[10][10];
int a,b;
cout<<"Enter 1st number from 0 to 9:";
cin>>a;
cout<<"Enter 2nd number from 0 to 9:";
cin>>b;
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
t[i][j]=i*j;
}
}
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
cout<<i<<"*"<<j<<"="<<t[i][j]<<endl;
}
}
}
#include<iostream>
usingnamespace std;
int main()
{
int t[10][10];
int a,b;
cout<<"Enter 1st number from 0 to 9:";
cin>>a;
cout<<"Enter 2nd number from 0 to 9:";
cin>>b;
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
t[i][j]=i*j;
cout<<i<<"*"<<j<<"="<<t[i][j]<<endl;
}
}
}