do while , for, Arrays

do while , for, Arrays

University

16 Qs

quiz-placeholder

Similar activities

Java_MCQ_3

Java_MCQ_3

University

15 Qs

GEE-109 LIVING IN AN IT ERA

GEE-109 LIVING IN AN IT ERA

University

20 Qs

PYTHON APTITUDE

PYTHON APTITUDE

University

12 Qs

Pemrograman Visual dan Scratch

Pemrograman Visual dan Scratch

7th Grade - University

15 Qs

KELAS 7 BAB 6 ANALISIS DATA C. Pengolahan Data Dasar

KELAS 7 BAB 6 ANALISIS DATA C. Pengolahan Data Dasar

7th Grade - University

20 Qs

UL_FPAS_S1

UL_FPAS_S1

University

15 Qs

LibreOffice Writer Styles Quiz

LibreOffice Writer Styles Quiz

10th Grade - University

15 Qs

Metode BK

Metode BK

University

16 Qs

do while , for, Arrays

do while , for, Arrays

Assessment

Quiz

Information Technology (IT)

University

Practice Problem

Medium

Created by

Fatma Metwally

Used 1+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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.

Access all questions and much more by creating a free account

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

Already have an account?