You are on page 1of 2

/*

This program will generate a multiplication table.

The user will input the size of the multiplication to generate,valid input is from 1-10 only.

*/

#include <iostream>

using namespace std;

int main()

{ int size, col, row, prod;

char tryagain;

do

{ system ("cls");

cout << "Input the size of multiplication table you want to generate(1-10 only) :" << endl;

do

cin>>size; //size input

if (size < 1 || size > 10) //size of the multiplication table

cout << size << " is an INVALID input! " <<endl; //the input is invalid

}while (size < 1 || size > 10);


for (row=1;row <= 10;row++) //row

for (col=1; col <= size;col++) //column

prod = row * col; //equation

cout <<row << " * " << col << " = " << prod << "\t";

cout <<endl;

cout << "Press any key to continue or X/x to exit"<<endl;

cin >> tryagain;

tryagain = tolower(tryagain);

} while (tryagain != 'x');

return 0;

You might also like