1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
/*
Objective: prompt user for a row and column space between 1 and 12 that do
not need to match. Program will print out a regular multipliction table
and then a multiplication table by 2's
*/
#include <iostream>
#include <iomanip>
using namespace std;
int userInput(int &row, int &col);
int regTable(int &row, int &col);
int evenTable(int &row, int &col);
int main()
{
int again, row, col;
again=1;
do
{
userInput(row,col);
regTable(row,col);
evenTable(row,col);
cout << "\nWould You Like To Run This Program Again? (Press 1 For Yes): ";
cin >> again;
}while (again==1);
system("PAUSE");
return 0;
}
int userInput(int &row, int &col)
{
cout << setw(40) << "Multiplication Tables\n";
cout << setw(40) << "---------------------\n\n" << endl << endl;
cout << "Please Enter The Number of Rows For Table (1-12 only): ";
cin >> row;
cout << endl;
while (row < 1 or row > 12)
{
cout << "Incorrect Number, Please Enter The Number of Rows Again (1-12 only): ";
cin >> row;
cout << endl;
}
cout << "Please Enter The Number of Columns For Table (1-12 only): ";
cin >> col;
cout << endl;
while (col < 1 or col > 12)
{
cout << "Incorrect Number, Please Enter The Number of Columns Again (1-12 only): ";
cin >> col;
cout << endl;
}
system("cls");
return(row,col);
}
int regTable(int &row,int &col)
{
int i, j;
i=0;
j=0;
cout << setw(36) << "Regular Multiplication Table" << endl;
cout << setw(36) << "----------------------------" << endl << endl;
for (i = 1; i <= row; i++)
{
for (j = 1; j <= col; j++)
cout << setw(6) << i*j;
cout << endl;
}
}
int evenTable(int &row, int &col)
{
int i, j;
i=0;
j=0;
cout << endl << endl;
cout << setw(41) << "Even Numbers Multiplication Table" << endl;
cout << setw(41) << "---------------------------------" << endl << endl;
for (i = 2; i <= row*2; i+=2)
{
for (j = 2; j <= col*2; j+=2)
cout << setw(6) << i*j;
cout << endl;
}
}
|