Answer to Question #310578 in C++ for nickname

Question #310578

Format the multiplication table exercise we did in class to include headers. All numbers and lines should be generated with loops. All columns are 4 characters wide, just like in class. The final output should look like this: 


1
Expert's answer
2022-03-13T03:33:20-0400
#include <iostream>
#include <iomanip>
using namespace std;


int main() {
    cout << "    |";
    for (int i=1; i<=10; i++) {
        cout << setw(4) << i;
    }
    cout << endl;
    cout << "----+";
    for (int i=1; i<=10; i++) {
        cout << "----";
    }
    cout << endl;


    for (int j=1; j<=10; j++) {
        cout << setw(4) << j << "|";
        for (int i=1; i<=10; i++) {
            cout << setw(4) << i*j;
        }
        cout << endl;
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog