Here is a different way to do the same thing. The only thing I added that you did not have was a 'clear screen' command. When running a program over and over it can get a little messy having everything on one screen.
Code:# include <iostream> # include <iomanip> using namespace std; int main () { int table; char runAgain = 'y'; do { cout << "What size table would you like (2 to 12)? "; cin >> table; cout << " | "; for (int a=0; a <=table; a++) cout << setw (5) << a; cout << endl; cout << "----------------------------------------------------" << endl; for (int across=0; across <=table; across++) { cout << setw (3) << across << setw (3) << " | " << ' '; for (int down=0; down <=table; down++) cout << setw (5) << down * across; cout << endl; } cout << "Run again?: "; cin >> runAgain; system("cls"); } while (runAgain == 'y' || runAgain == 'Y'); return 0; }




Reply With Quote