arrow
arrow
arrow
Observe the following flowchart and find the output.
Question

Observe the following flowchart and find the output.

A.

180

B.

120

C.

100

D.

160

Correct option is A

The flowchart initializes two variables: A = 100 and S = 0. The program then checks the condition A 20 and performs a loop until the condition becomes false. In each iteration, the value of A is added to S, and then A is decreased by 40.

Step-by-step working:

Initial values:
A = 100, S = 0

Iteration 1:
Condition check → 100 20 → TRUE
S = S + A → S = 0 + 100 = 100
A = A − 40 → A = 60

Iteration 2:
Condition check → 60 20 → TRUE
S = S + A → S = 100 + 60 = 160
A = A − 40 → A = 20

Iteration 3:
Condition check → 20 20 → TRUE
S = S + A → S = 160 + 20 = 180
A = A − 40 → A = -20

Next condition check → -20 20 → FALSE

The loop terminates and the program displays the value of S.

Therefore, the final OUTPUT S = 180.

Important Key Points:

  1. The flowchart initializes variables as A = 100 and S = 0.
  2. The loop continues while the condition A 20 remains true.
  3. In each iteration, A is added to S, and then A decreases by 40.
  4. The loop stops when A becomes less than 20, and the final value of S is printed.

Knowledge Booster:

  • 120: This value would occur only if the loop executed incorrectly or skipped one iteration, which does not follow the flowchart logic.
  • 100: This represents only the first iteration result (S = 100) and ignores the remaining valid iterations.
  • 160: This value appears after the second iteration, but the condition 20 20 is still true, so one more iteration must occur before termination.

Free Tests

Free
Must Attempt

DSSSB PRT Full Mock - 01

languageIcon English
  • pdpQsnIcon200 Questions
  • pdpsheetsIcon200 Marks
  • timerIcon120 Mins
languageIcon English
Free
Must Attempt

Educational Psychology & Pedagogy - 01

languageIcon English
  • pdpQsnIcon20 Questions
  • pdpsheetsIcon20 Marks
  • timerIcon15 Mins
languageIcon English
Free
Must Attempt

DSSSB PRT PYP Held on 7th March 2022 Shift 1

languageIcon English
  • pdpQsnIcon200 Questions
  • pdpsheetsIcon200 Marks
  • timerIcon120 Mins
languageIcon English
test-prime-package

Access ‘EMRS PGT’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
368k+ students have already unlocked exclusive benefits with Test Prime!
Our Plans
Monthsup-arrow