Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.216.145.37
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/assterling/../kabillups/../pswoodson/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/assterling/../kabillups/../pswoodson/prog4.cpp
//***************************************
//* Programming Assignment 4            *
//*                                     *
//* Mulitication table using "for loops"*
//*                                     *
//* Written By: Paula S. Woodson        *
//* October 29, 2008                    *
//***************************************

// Preprocessor directives

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

// Main function

int main()
{

  int
  i,     //  counter variable
  j,     //  counter variable
  r,     //  vaule
  n;     //  multiplication number

    cout << "Enter size of multiplication fact table: ";
    cin  >> n;

while (n < 2 || n > 20)
    {
       cout << "\n\n!!! Multiplication table Must be in range 2 - 20 !!!";
       cout << "\n\nPlease re-enter Multiplication number: ";
       cin  >> n;
    }

  if (n <= 4)
    cout << setw(n);
  else
   cout << setw(n + 7);

  cout << n << " x " << n << " Multiplicaton Table \n";   
  cout <<"   ";

// "for loops" for the heading

  for (i = 1; i <= n; i++)
       cout << setw(4)<< i;

  cout <<"\n";
  cout << "----";

  for (i = 1; i <= n; i++)   
       cout <<"----";  
   
// "for loops" for the body

  for (i = 1; i <= n; i++)
   {
	cout << "\n" << setw(2) <<  i << "|";
        for (j = 1 ; j <= n; j++)
        {
              r = i * j;
              cout <<setw(4) << r;
        }
   }

  cout <<"\n";
}

Stv3n404 - 2023