Create a program using C++ that prints out a multiplcation table up to a specfic
ID: 3549904 • Letter: C
Question
Create a program using C++ that prints out a multiplcation table up to a specfic limit. The code should prompt the user for the limit and then print out the table. You will need nested for loops. To align the values, try using setw(4) in the cout statement (a decimal integer, right aligned, with 4 spaces).
Output Should be:
Enter size of the table: 4
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
Please help me by writing a code that gives this output, full rating given to anyone that can help! Spam for tutoring will be flagged.
Explanation / Answer
#include<iostream>
using namespace::std;
int main(void)
{
int M = 4;
int N = 4;
for(int i = 0; i <= M;i++)
{
for(int j = 0 ; j <= N; j++)
{
cout << i * j << " ";
}
cout << endl;
}
}
This should give you the output of:
0 0 0 0 0
0 1 2 3 4
0 2 4 6 8
0 3 6 9 12
0 4 8 12 16
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.