Advertisement
Taco2k

Untitled

Oct 10th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6.     int size;
  7.  
  8.     cout << "Welcome to my Multiplication Table Generator." << endl << endl;
  9.     cout << "Enter a size (1-15) of which you want your multiplication table to be: ";
  10.     cin >> size;
  11.  
  12.     if (size > 15 || size < 0) {
  13.         cout << "Error! You entered a value outside the range (1-15).";
  14.     }
  15.    
  16.     cout << setw(4) << "" << "|";
  17.     for (int i = 1; i <= size; i++) {
  18.         cout << setw(4) << i;
  19.     }
  20.     cout << endl;
  21.  
  22.     cout << "____| ";
  23.     for (int i = 1; i <= size; i++) {
  24.         cout << "____";
  25.     }
  26.     cout << endl;
  27.  
  28.     for (int i = 1; i <= size; i++) {
  29.         cout << setw(4) << i << "|";
  30.         for (int j = 1; j <= size; j++) {
  31.             cout << setw(4) << (j * i);
  32.         }
  33.         cout << endl;
  34.     }
  35.  
  36.     cin.ignore();
  37.     cin.get();
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement