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...

Avaliação: WAEC SSCE - Computer Studies - 2016 (Objective) Disciplina: Computer Studies

Pergunta 1 Relatório

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? 

Detalhes da Resposta
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.

Descarregar a aplicação na Google Play Store

Tudo o que precisas para te destacares no JAMB, WAEC e NECO.

Green Bridge CBT Mobile App
Assistente de Chat de Aprendizagem Personalizada com IA
Mais de 200.000 questões de exame do IGCSE, JAMB, WAEC e NECO
Mais de 1200 Notas de Aula
Suporte Offline - Aprenda a Qualquer Hora, em Qualquer Lugar
Horário da Ponte Verde
Resumos de Literatura & Possíveis Perguntas
Acompanhe o Seu Desempenho e Progresso
Explicações Detalhadas para uma Aprendizagem Abrangente