Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- int size;
- cout << "Welcome to my Multiplication Table Generator." << endl << endl;
- cout << "Enter a size (1-15) of which you want your multiplication table to be: ";
- cin >> size;
- if (size > 15 || size < 0) {
- cout << "Error! You entered a value outside the range (1-15).";
- }
- cout << setw(4) << "" << "|";
- for (int i = 1; i <= size; i++) {
- cout << setw(4) << i;
- }
- cout << endl;
- cout << "____| ";
- for (int i = 1; i <= size; i++) {
- cout << "____";
- }
- cout << endl;
- for (int i = 1; i <= size; i++) {
- cout << setw(4) << i << "|";
- for (int j = 1; j <= size; j++) {
- cout << setw(4) << (j * i);
- }
- cout << endl;
- }
- cin.ignore();
- cin.get();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement