int x = 5;
if (x > 3) {
cout << "Big";
} else {
cout << "Small";
}
What will this code print?
Level Two Quiz
Quiz
•
Information Technology (IT)
•
6th - 8th Grade
•
Hard
Salma Ghoneim
FREE Resource
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
int x = 5;
if (x > 3) {
cout << "Big";
} else {
cout << "Small";
}
What will this code print?
Small
Error
Big
Nothing
Answer explanation
The variable x is initialized to 5. The condition x > 3 evaluates to true, so the code inside the if block executes, printing 'Big'. Therefore, the correct answer is 'Big'.
2.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How many times will this loop run?
for (int i = 0; i < 3; i++)
{ cout << i; }
1
2
3
4
Answer explanation
The loop starts with i = 0 and runs while i < 3. It increments i by 1 each iteration. Therefore, it runs for i = 0, 1, and 2, totaling 3 iterations. Thus, the correct answer is 3.
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
How do you access the third element in this array?
int arr[5] = {10, 20, 30, 40, 50};
arr[2]
arr(3)
arr.3
arr[3]
Answer explanation
In C, array indexing starts at 0. Therefore, the third element is accessed using arr[2]. The other options are incorrect because arr(3) and arr.3 are not valid syntax, and arr[3] refers to the fourth element.
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the purpose of an if statement in C++?
To repeat code many times
To make decisions
To print a message
To define a new function
Answer explanation
The purpose of an if statement in C++ is to make decisions by executing certain code blocks based on whether a specified condition is true or false. This allows for conditional execution of code.
5.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is special about a do while loop?
It never stops
It doesn’t need a condition
It runs at least once
It doesn’t use a variable
Answer explanation
A do while loop is unique because it guarantees that the loop body will execute at least once, regardless of the condition. This is due to the condition being checked after the loop's body has run.
6.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
When does a while loop check the condition?
Before the loop starts
After the loop ends
Only in the middle
It doesn’t check
Answer explanation
A while loop checks the condition before the loop starts. If the condition is true, the loop executes; if false, it terminates. This ensures that the loop only runs when the condition is satisfied.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is a array in C++?
A type of loop
A list of values stored in order
A group of if statements
A kind of function
Answer explanation
An array in C++ is a list of values stored in order, allowing for efficient access and manipulation of multiple items of the same type. This distinguishes it from loops, functions, or conditional statements.
12 questions
Review loops
Quiz
•
8th Grade - University
12 questions
Round 2 - Week5
Quiz
•
7th Grade
10 questions
Computer Science FFF QUIZ
Quiz
•
6th Grade
15 questions
Quiz sobre el ornitorrinco y la programación
Quiz
•
8th Grade - University
10 questions
Lego Spike & Python - Challenge 3 Quiz
Quiz
•
6th - 8th Grade
12 questions
Strand D-Coding
Quiz
•
6th Grade
15 questions
IT/CS Review Quizzizz
Quiz
•
6th Grade - University
10 questions
ict quiz
Quiz
•
7th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
20 questions
Final Exam Vocabulary
Quiz
•
6th Grade
17 questions
Parts of Speech
Quiz
•
7th - 12th Grade
11 questions
Decimal/fraction conversions quick check
Quiz
•
5th - 7th Grade
10 questions
Identifying equations
Quiz
•
KG - University
44 questions
El fin del año- 7th
Quiz
•
7th - 12th Grade
40 questions
Word Study Assessment: Roots, Prefixes, Suffixes, and Vocabulary
Quiz
•
8th Grade
49 questions
How Well Do You Know Your 6th Grade Teachers?
Quiz
•
6th Grade