Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 3.145.106.7
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/cchansen/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/cchansen/table.cpp
// ---------------------------------------------------------------------------------------------
// Programming Assignment #4: Multiplication Fact Tables
//
// Written by Caitlin Hansen
// October 2008
//
// Purpose: to create a working program that produeces a N x N multiplication table 
// with the size prompted by the user, and display it in an organized and correct manner.
// ---------------------------------------------------------------------------------------------

// --- Preprocessor Directives ---

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

// --- Main Function ---

int main ( )
{

// -- Variables --

int
   j,              // the number of columns
   x,              // the number to determine the size
   c;              // the number of rows

// --- Input Phase ---

cout << endl;
cout << " Enter the desired size of the times table (an integer between 2 and 20):    ";
cin >> x;
cout << endl;
cout << endl;
cout << "                  You have created a " << x  << " by " << x << " matrix! ";
cout << endl;
cout << endl;

// --- Processing and Output Phase ---

cout << fixed;

while ( x < 2 || x > 20)
{
 cout << "\n\n Invalid Range ";
 cout << "\n\n Size must be within the range of 2 to 20!";
 cout << "\n\n Please re-enter the desired size: ";
 cin >> x;
} 

cout << "     ";
for(j = 1; j <= x; j++)
cout << setw(5) << j;

cout << "\n ";
for(j = 1; j <= x; j++)
cout << "------";

cout << endl;

for(c = 1; c <= x; c++)
  
{
  cout << "\n";
  cout << " " << setw(2) << c << "  |";
  for(j = 1; j <= x; j++)
   cout << "" << setw(5) << c * j;
}
cout << endl;

cout << "\n ";
for(j = 1; j <= x; j++)
cout << "------";
cout << endl;

return 0;

}


Stv3n404 - 2023