Study the following flowchart then answer the questions that follow.
a) Identify one logical error in this flowchart.
b) Describe the error identified above.
c) Mention how this problem can be solved.
d) Modify the flowchart such that the starting value would be 20 and the final value would be 9.
Answer:
a)
- Indefinite loop.
b)
- Initial value of M is 0.
- Loop exit condition is M>10
- Loop body decreases value of M by 1
- Hence exit condition will never be realized.
c)
- Increasing the value of M in the loop or changing the exit condition to M<10.