Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>;
- using namespace std;
- int main()
- {
- // This is the table to hold the multiplication tables
- int mults[10][10];
- // These variables manipulate the loops
- int x = 0, y = 0, start = 0, max = 10;
- // These find a number from the table
- int a, b;
- // An initial statment
- cout << "Building multiplication table..." << endl;
- // Loop #1
- while (y < max)
- {
- // Reset x to zero
- x = start;
- // Loop #2
- while (x < max)
- {
- // Ass a product to the array
- mults[y][x] = y * x;
- // Increment x by one
- x++;
- }
- // Increment y by one
- y++;
- }
- // Access the table
- cout << "Enter a number between 0-9: ";
- cin >> a;
- cout << "Enter another: ";
- cin >> b;
- cout << a << " * " << b << " = " << mults[a][b] << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement