← All questions
RareComputer science

What value of D does the flowchart output for A = 16, B = 10?

Short answer
13

Exercise

What value of D does the flowchart output for A = 16, B = 10?

Solution

(16, 10) → (15, 11) → (14, 12) → (13, 13) → D = 13

While A exceeds B the chart subtracts one from A and adds one to B. Their sum stays twenty-six, while the gap shrinks by two each iteration. They coincide after three iterations. The equality branch assigns A itself to D.

A + B = 26. A − B: 6 → 4 → 2 → 0. A = B = 26/2 = 13. D = A = 13.

Trace the instructions in order. A test reads the current values, an assignment replaces a value, and output uses the value present when execution reaches it. Recording each new state makes the result checkable.

Conditionals

Platforms

  • MAXIMUM

Download now and try it for free on your own tasks!

10 15 free credits • No credit card required
Version: Loading…

Choose the Windows app or the Chrome extension with phone controls.