do while , for, Arrays

do while , for, Arrays

University

16 Qs

quiz-placeholder

Similar activities

Kelas 8 - Halaman 10 (UH Bab 1)

Kelas 8 - Halaman 10 (UH Bab 1)

8th Grade - University

20 Qs

NTRFAN

NTRFAN

University

20 Qs

Session 08: Array

Session 08: Array

University

16 Qs

MakeCode Arcade Questions

MakeCode Arcade Questions

10th Grade - University

15 Qs

Quiz Pemrograman Arduino

Quiz Pemrograman Arduino

10th Grade - University

15 Qs

Fundamentos Java

Fundamentos Java

University

20 Qs

Mảng 2 chiều trong C

Mảng 2 chiều trong C

University

16 Qs

Quiz on Loops and Iteration in Python

Quiz on Loops and Iteration in Python

University

20 Qs

do while , for, Arrays

do while , for, Arrays

Assessment

Quiz

Information Technology (IT)

University

Medium

Created by

Fatma Metwally

Used 1+ times

FREE Resource

16 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which loop type will always execute at least once, regardless of the condition?

do-while loop

while loop

for loop

foreach loop

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

If a for loop has a condition i < 10, but inside the loop, we have a statement i += 3;, how many times will it run starting from i = 0?

6

4

3

5

Answer explanation

Starting from i = 0, the loop increments i by 3 each time: 0, 3, 6, 9. After that, i becomes 12, which is not less than 10. Thus, the loop runs 4 times before exiting.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following correctly initializes a 2D array in C++ with all zeros?

  • int arr[3][3] = {};

  • int arr[3][3] = {0};

  • int arr[3][3] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };

  • All of the above

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which loop is most appropriate for iterating over elements when the number of iterations is known in advance?

do-while loop

while loop

for loop

foreach loop

5.

MULTIPLE SELECT QUESTION

45 sec • 1 pt

Which statement about arrays in C++ is true?

  • Array indices start at 1.

Arrays in C++ can store elements of different types.

Arrays in C++ store elements of the same type.

  • Array size must be specified at the time of declaration.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In a 2D array declared as int matrix[3][3];, how do you access the element at the first row and second column?

matrix[0][1]

matrix[0][2]

matrix[2][1]

matrix[1][0]

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Media Image

What will be the output of the following code?

  • 100

20

90

40

Answer explanation

The loop accesses elements at indices 1 and 3 (arr[1] = 20, arr[3] = 40), so sum = 20 + 40 = 60.

Create a free account and access millions of resources

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?