Question #24286

how can i print a multiplication table of 7

Expert's answer

#include <conio.h>
#include <iomanip>
#include <iostream>

using namespace std;

/* Prints the row separator */
void print_separator()
{
for (int n = 0; n < 59; n++)
cout << "-";
cout << endl;
}

void main()
{
/* Print the table header */
cout << " |";
for (int n = 0; n <= 10; n++)
cout << setw(3) << n << " |";

cout << endl;
print_separator();

/* Print the table body */
cout << " 7 |";
for (int n = 0; n <= 10; n++)
cout << setw(3) << n * 7 << " |";

cout << endl;
print_separator();

_getch();
}
LATEST TUTORIALS
APPROVED BY CLIENTS