Answer to Question #22647 in C++ for airi

Question #22647
how to display a multiplication table with 1-10 fixed (rows)
1
Expert's answer
2013-01-23T08:12:27-0500
#include <conio.h>
#include <iomanip>
#include <iostream>

using namespace std;

void main()
{
/* Print row separating line */
cout << " quot;;
for (int n = 0; n <= 50; n++)
cout << '-';
cout << endl;

/* Print table column headers */
cout << " & |";
for (int n = 1; n <= 10; n++)
cout << setw(3) << n << " |";
cout << endl;

/* Print row separating line */
for (int n = 0; n < 55; n++)
cout << '-';
cout << endl;

for (int row = 1; row <= 10; row++)
{
cout << '|' << setw(3) << row << " |"; //print row header
for (char col = 1; col <= 10; col++)
cout << setw(3) << row * col << " |";
cout << endl;

/* Print row separating line */
for (int n = 0; n < 55; n++)
cout << '-';
cout << endl;
}
getch();
}

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
APPROVED BY CLIENTS