
do while , for, Arrays

Quiz
•
Information Technology (IT)
•
University
•
Medium
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
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
Similar Resources on Wayground
20 questions
Introduction to C# Programming

Quiz
•
10th Grade - University
15 questions
PPL 223 - (QUIZ 3) Data Types and Structures

Quiz
•
University
20 questions
quiz1B1

Quiz
•
7th Grade - University
15 questions
Module 5: Creating Dynamic Web Pages with Scripting

Quiz
•
University
14 questions
PHP Programming Quiz 2

Quiz
•
University
12 questions
Review loops

Quiz
•
8th Grade - University
14 questions
Data Structures and Algorithms Quiz

Quiz
•
University
20 questions
Python Quiz Girls in ICT Day

Quiz
•
University
Popular Resources on Wayground
12 questions
Unit Zero lesson 2 cafeteria

Lesson
•
9th - 12th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
20 questions
Lab Safety and Equipment

Quiz
•
8th Grade
13 questions
25-26 Behavior Expectations Matrix

Quiz
•
9th - 12th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Information Technology (IT)
15 questions
Let's Take a Poll...

Quiz
•
9th Grade - University
2 questions
Pronouncing Names Correctly

Quiz
•
University
12 questions
Civil War

Quiz
•
8th Grade - University
18 questions
Parent Functions

Quiz
•
9th Grade - University
21 questions
Mapa países hispanohablantes

Quiz
•
1st Grade - University
19 questions
Primary v. Secondary Sources

Quiz
•
6th Grade - University
25 questions
Identifying Parts of Speech

Quiz
•
8th Grade - University
20 questions
Disney Trivia

Quiz
•
University