Source Code:
// Multiplication Table
// Author: Yanni Nietcho
// Date: October 27, 2024
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
// Variables for # rows and columns
int rows, columns;
// Ask the user for input
cout<<"Multiplication Table Tool\n";
cout<<"How many rows would you like? ";
cin>>rows;
cout<<"How many columns would you like? ";
cin>>columns;
// Print column headers
cout << setw(4) << " ";
for (int col = 1; col <= columns; ++col) {
cout << setw(4) << col;
}
cout << endl;
// Print rows with row numbers and multiplication results
for (int row = 1; row <= rows; ++row) {
cout<<setw(2) << row << "| ";
for (int col = 1; col <= columns; ++col) {
cout<< setw(4) << row * col;
}
cout<<endl;
}
return 0;
Output:PS C:\Users\N.W.C.L LLC\Desktop> cd "c:\Users\N.W.C.L LLC\Desktop\" ; if
($?) { g++ [Link] -o NestedLoopsHw } ; if ($?) { .\NestedLoopsHw }
Multiplication Table Tool
How many rows would you like? 5
How many columns would you like? 6
1 2 3 4 5 6
1| 1 2 3 4 5 6
2| 2 4 6 8 10 12
3| 3 6 9 12 15 18
4| 4 8 12 16 20 24
5| 5 10 15 20 25 30
PS C:\Users\N.W.C.L LLC\Desktop>