College

C++ Please

**LAB: Multiplication Tables**

This program prints out the first ten lines of a multiplication table of the number 5.

**Example output:**
```
5 x 1 = 5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
```

1. **Modify the program** so the user chooses the number to multiply.

**Example output if the user enters 7:**
```
Enter a number:
7
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70
```

2. **Extend the program** so the user chooses how many lines of the table to display. This will generate a second table.

**Example output if the user enters 7 and 6:**
```
Enter a number:
7
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70

Enter the number of rows to display:
6
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
```

3. **Extend the program** so the second table is displayed backwards. Leave a blank line between the tables.

**Example output if the user enters 7 and 6:**
```
Enter a number:
7
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42
7 x 7 = 49
7 x 8 = 56
7 x 9 = 63
7 x 10 = 70

Enter the number of rows to display:
6
7 x 1 = 7
7 x 2 = 14
7 x 3 = 21
7 x 4 = 28
7 x 5 = 35
7 x 6 = 42

7 x 6 = 42
7 x 5 = 35
7 x 4 = 28
7 x 3 = 21
7 x 2 = 14
7 x 1 = 7
```

Answer :

Final answer:

To modify the program to allow the user to choose the number to multiply and the number of lines to display, you can use user input and loops in C++. Here is an example of how to modify the program:

  1. Declare two integer variables, 'number' and 'lines'.
  2. Prompt the user to enter a number and store the input in 'number'.
  3. Prompt the user to enter the number of rows to display and store the input in 'lines'.
  4. Use a 'for' loop to iterate from 1 to 'lines' and display the multiplication table for the chosen number and the current iteration value.
  5. Insert a blank line.
  6. Use another 'for' loop to iterate from 'lines' to 1 and display the multiplication table in reverse order.

Explanation:

To modify the program to allow the user to choose the number to multiply and the number of lines to display, we need to use user input and loops. In C++, we can use the 'cin' function to get user input and the 'for' loop to iterate through the multiplication table. By using a nested loop, we can display the table in reverse order.

Here is an example of how to modify the program:

By modifying the program in this way, the user can choose the number to multiply and the number of lines to display, and the program will generate the corresponding multiplication table.

Learn more about modifying a program to print a multiplication table based on user input here:

https://brainly.com/question/29571743

#SPJ14