86.4k views
1 vote
You require an algorithm that will receive an integer from the screen, add 5 to it, double it, subtract 7 from it, and display the final number to the screen.

User Jhonny
by
5.2k points

1 Answer

3 votes

Answer:

The algorithm is as follows:

1. Start

2. Input num

3. num = num + 5

4. num = 2 * num

5. num = num - 7

6. Print num

7. Stop

Step-by-step explanation:

The first and the last line of the algorithm starts and ends the algorithm

Line 2 gets user input;

Assume user input is 9

num = 9

Line 3: adds 5 to the inputted number

num = 9 + 5 = 14

Line 4 doubles the result of line 3

num = 2 * 14 = 28

Line 5 subtracts 7 from the result of 4

num = 28 - 7 = 21

Line 6 prints the output to the screen

Hence, the output of the algorithm is 21 if the user input is 9

User Pavan Patel
by
5.3k points