
C++ Basics Quiz
Authored by Maria Macuha
Information Technology (IT)
University
Used 2+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
25 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
Which operator checks if two values are equal?
=
==
!=
<=
2.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
What will be printed? int x = 10, y = 20; if (x < y) cout << "Yes"; else cout << "No";
Yes
No
Error
Nothing
Answer explanation
The condition 'x < y' evaluates to true since 10 is less than 20. Therefore, the program executes the first branch of the if statement, printing 'Yes'.
3.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
Which statement correctly checks if n is negative?
if (n = 0)
if (n < 0)
if (n <= 0)
if (n == 0)
Answer explanation
The correct statement to check if n is negative is 'if (n < 0)'. This condition evaluates to true when n is less than zero, accurately identifying negative numbers. The other options do not correctly check for negativity.
4.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
Which keyword is used when the if condition is false?
elseif
switch
else
continue
Answer explanation
The keyword 'else' is used to define a block of code that executes when the 'if' condition is false. It provides an alternative path in conditional statements.
5.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
What is the output if the user enters -5? int value; cin >> value; if (value < 0) value = -value; cout << value;
-5
5
0
Error
Answer explanation
When the user enters -5, the condition 'value < 0' is true, so 'value' is set to -(-5), which is 5. Therefore, the output is 5.
6.
MULTIPLE CHOICE QUESTION
20 sec • 1 pt
What is the logical AND operator in C++?
||
&&
!
&
Answer explanation
The logical AND operator in C++ is represented by '&&'. It evaluates to true only if both operands are true. The other options represent different operations: '||' is OR, '!' is NOT, and '&' is bitwise AND.
7.
MULTIPLE CHOICE QUESTION
20 sec • 2 pts
Which code correctly checks if a number is even?
if (n/2)
if (n % 2 == 0)
if (n % 2)
if (n == 2)
Answer explanation
The correct choice is 'if (n % 2 == 0)', which checks if the remainder of n divided by 2 is zero, indicating that n is even. The other options do not correctly determine if a number is even.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
20 questions
QUIZ 2 - SỬ DỤNG BẢNG TÍNH CƠ BẢN -ICC
Quiz
•
University
20 questions
Kompetensi 8 Uji LSP
Quiz
•
12th Grade - University
20 questions
Algoritma Struktur Data
Quiz
•
University
20 questions
Python Quiz Girls in ICT Day
Quiz
•
University
20 questions
Pengenalan Bahasa Pemrograman Python
Quiz
•
9th Grade - University
24 questions
Cryptology and Modern Network Security Quiz
Quiz
•
University
25 questions
Seatwork #4
Quiz
•
12th Grade - University
22 questions
ÔN TẬP CRV1
Quiz
•
6th Grade - University
Popular Resources on Wayground
8 questions
2 Step Word Problems
Quiz
•
KG - University
20 questions
Comparing Fractions
Quiz
•
4th Grade
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
10 questions
Latin Bases claus(clois,clos, clud, clus) and ped
Quiz
•
6th - 8th Grade
22 questions
fractions
Quiz
•
3rd Grade
7 questions
The Story of Books
Quiz
•
6th - 8th Grade
Discover more resources for Information Technology (IT)
8 questions
2 Step Word Problems
Quiz
•
KG - University
7 questions
Comparing Fractions
Interactive video
•
1st Grade - University
7 questions
Force and Motion
Interactive video
•
4th Grade - University
10 questions
14.2 Independent/Dependent Variables
Quiz
•
KG - University
18 questions
Great Lakes States
Quiz
•
KG - University
7 questions
DNA, Chromosomes, Genes, and Traits: An Intro to Heredity
Interactive video
•
11th Grade - University
7 questions
Reflexive Verbs in Spanish
Lesson
•
9th Grade - University
7 questions
Narrative Writing 1
Interactive video
•
4th Grade - University