Use the BASIC program below to answer questions 23 to 25 10 LET K = 2 20 LET L = 9 30 LET SUM = 0 40 FOR J = K TO STEP 2 50 SUM = SUM + J\(^2\) 60 PRINT "AN...

Prüfung: WAEC SSCE - Computer Studies - 2016 (Objective) Fach: Computer Studies

Frage 1 Bericht

Use the BASIC program below to answer questions 23 to 25

10 LET K = 2

20 LET L = 9

30 LET SUM = 0

 40 FOR J = K TO STEP 2

50 SUM = SUM + J\(^2\)

60 PRINT "ANSWER =", SUM

70 NEXT J

80 END

How many times will the statement lines 50 and 60 be repeated? 

Antwortdetails
The statement in line 40 sets up a loop that will run from the value of K to a final value (not specified in the program). The "STEP 2" in line 40 indicates that the loop variable J will be incremented by 2 at each iteration. Since K is initialized to 2 in line 10, the loop will start with J = 2. The final value of J is not specified in the program, but we can see that the loop will continue as long as J is less than or equal to L (which is initialized to 9 in line 20). Therefore, the values of J that will be used in the loop are 2, 4, 6, 8. This means that the statements in lines 50 and 60 will be repeated 4 times. So the answer is (C) 4.

Lade die App im Google Playstore herunter.

Alles, was du brauchst, um in JAMB, WAEC & NECO zu glänzen.

Green Bridge CBT Mobile App
Personalisierter KI-Lern-Chat-Assistent
Über 200.000 Prüfungsfragen für IGCSE, JAMB, WAEC und NECO.
Über 1200 Unterrichtsnotizen
Offline-Unterstützung - Lernen jederzeit und überall
Fahrplan der Grünen Brücke
Literaturzusammenfassungen & Potenzielle Fragen
Verfolgen Sie Ihre Leistung und Ihren Fortschritt
Detaillierte Erklärungen für umfassendes Lernen