Question 3

How many times the below FOR LOOP gets executed ? <SCRIPT LANGUAGE = "VBScript">

How many times the below FOR LOOP gets executed ? <SCRIPT LANGUAGE = "VBScript"> Q = 29 FOR AGE = 5 to Q STEP 6 DOCUMENT.WRITE P NEXT </SCRIPT>
  1. A4 times
  2. B5 times
  3. CIt will not execute as STEP parameter is wrong
  4. DIt will not execute as P is not enclosed in ( )
Show answerHide answer

Correct answer: (B) 5 times

Explanation

Corrected: the book's key says (d). The loop runs for AGE = 5, 11, 17, 23, 29, i.e. 5 times.

From DSSSB TGT Computer Science Practice Set 2

This is question 3 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.