Repetition Control Structures Quiz

Repetition Control Structures Quiz

Professional Development

12 Qs

quiz-placeholder

Similar activities

Final Assessment

Final Assessment

Professional Development

16 Qs

Pre-Programming Day 4

Pre-Programming Day 4

University - Professional Development

13 Qs

Examen 2

Examen 2

Professional Development

13 Qs

c program -basic

c program -basic

Professional Development

10 Qs

IoT - E11

IoT - E11

Professional Development

10 Qs

Quiz de Python Básico

Quiz de Python Básico

Professional Development

12 Qs

K3MT 201920 SC 025 (Repetition #1)

K3MT 201920 SC 025 (Repetition #1)

1st Grade - Professional Development

12 Qs

AppsLab_Q3

AppsLab_Q3

1st Grade - Professional Development

12 Qs

Repetition Control Structures Quiz

Repetition Control Structures Quiz

Assessment

Quiz

Computers

Professional Development

Medium

Created by

ZURAIDAH Moe

Used 2+ times

FREE Resource

12 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a repetition control structure in programming?

To execute a block of code only once

To execute a block of code repeatedly based on a condition

To create a new function

To define a variable

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a 'for' loop, which part is responsible for updating the loop variable?

Termination

Updating

Condition

Initialization

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code segment output? 'for (int i = 0; i < 5; i++) { System.out.print(i); }'

01235

12345

01234

54321

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? 'int sum = 0; for (int i = 0; i < 5; i++) { sum += i; } System.out.print(sum);'

5

15

10

0

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a 'while' loop, what happens if the condition is false at the start?

The loop executes indefinitely

The loop executes twice

The loop executes once

The loop does not execute at all

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a sentinel value in a loop?

To define a function

To initialize a variable

To terminate the loop based on a specific condition

To create an infinite loop

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following Java code snippets correctly calculates the total, average, and frequency of numbers entered by the user?

int total = 0, count = 0, freq = 0;

Scanner sc = new Scanner(System.in);

while (true)

{ int number = sc.nextInt();

if (number == -1) break;

total += number;

count++;

if (number == specificNumber) freq++;

}

double average = (double) total / count;

int total = 0, count = 0;

Scanner sc = new Scanner(System.in);

while (sc.hasNextInt())

{ total += sc.nextInt();

count++;

}

double average = total / count;

int total = 0, count = 0;

Scanner sc = new Scanner(System.in);

while (sc.hasNextInt()) {

total += sc.nextInt();

count++;

}

double average = total / count;

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?