Question 76

Observe the following flowchart and find the output. Flowchart: START → A = 100, S = 0 → decision "IS A >= 20 ?": if YES → S += A → A −= 40 → back to the…

Observe the following flowchart and find the output. Flowchart: START → A = 100, S = 0 → decision "IS A >= 20 ?": if YES → S += A → A −= 40 → back to the decision; otherwise → OUTPUT S → STOP.
  1. A180
  2. B120
  3. C100
  4. D160
Show answerHide answer

Correct answer: (A) 180

Explanation

A=100: S=100, A=60. A=60: S=160, A=20. A=20 (still ≥ 20): S=180, A=−20. The condition is now false, so the output is 180.

From DSSSB TGT Computer Science Practice Set 2

This is question 76 of DSSSB TGT Computer Science Practice Set 2. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.