Option 6: Print a multiplication table. Ask the user to enter a max value. Your
ID: 3587541 • Letter: O
Question
Option 6: Print a multiplication table. Ask the user to enter a max value. Your program should then print a multiplication table from 0 to the max value. Note on the multiplication table: For full credit the multiplication table should be of the following format. If you do not include the headers then your max score for the assignment will be 9 The example uses max value 3. The top row shows and first column show the value for the row/column of the table.
0 1 2 3
0 0 0 0 0
1 0 1 2 3
2 0 2 4 6
3 0 3 6 9
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int n;
cout << "Enter the number: " << endl;
cin >> n;
cout<<" ";
for(int i=0;i<=n;i++) {
cout<<i<<" ";
}
cout<<endl;
for(int i=0;i<=n;i++) {
cout<<i<<" ";
for(int j=0;j<=n;j++){
cout<<i*j<<" ";
}
cout<<endl;
}
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.