#include #include #include using namespace std; int main() { int number{0}; int limit{0}; cout << "Enter a positive integer for which to print a multiplication table: "; cin >> number; if(!cin) { cerr << "Could not perform input.\n"; return EXIT_FAILURE; } if(number <= 0) { cerr << "Sorry, the number must be positive.\n"; return EXIT_FAILURE; } cout << "Up to what multiple should I go? "; cin >> limit; if(!cin) { cerr << "Could not perform input.\n"; return EXIT_FAILURE; } if(limit <= 0) { cerr << "Sorry, the limit must be positive.\n"; return EXIT_FAILURE; } cout << "\nMultiplication Table for " << number << "\n"; cout << "-------------------------------\n"; for(int i{1}; i <= limit; ++i) { const int product{number * i}; cout << setw(2) << number << " x " << setw(2) << i << " = " << setw(4) << product << "\n"; } return EXIT_SUCCESS; }