Question 79

Which of the following flow charts will be most appropriate for finding sum of first 10 multiples of 5?

  1. AS=0 → I=5 → decision 'IS I<=50?' — NO: PRINT S; YES: S=S+I → I=I+5 → back to the decision.
  2. BS=0 → I=5 → decision 'IS I<=50?' — NO: PRINT S; YES: I=I+5 → S=S+I → back to the decision.
  3. CI=1 → S=0 → decision 'IS I<=10?' — NO: PRINT S; YES: S=S+5*I → I=I+5 → back to the decision.
  4. DS=0 → I=1 → decision 'IS I<=10?' — NO: PRINT S; YES: I=I+1 → S=S+5*I → back to the decision.
Show answerHide answer

Correct answer: (A) S=0 → I=5 → decision 'IS I<=50?' — NO: PRINT S; YES: S=S+I → I=I+5 → back to the decision.

Explanation

The first 10 multiples of 5 are 5 to 50. Flowchart A starts at I = 5, adds I to S and then increases I by 5 while I ≤ 50. B increases I before adding, so it sums 10 to 55.

From DSSSB TGT Computer Science Practice Set 5

This is question 79 of DSSSB TGT Computer Science Practice Set 5. 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.