
C++ Basics Quiz

Quiz
•
Information Technology (IT)
•
University
•
Hard
Maria Macuha
Used 2+ times
FREE Resource
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.
Create a free account and access millions of resources
Similar Resources on Wayground
23 questions
JAVA - Day1

Quiz
•
University
30 questions
PAT_AIJ_XII-TKJ

Quiz
•
12th Grade - University
20 questions
latsol PH Informatika kelas 11 Jarkom

Quiz
•
11th Grade - University
24 questions
Icebreaker

Quiz
•
University
20 questions
Web Development Quiz

Quiz
•
University
23 questions
2.1.3 Network Topology

Quiz
•
University
23 questions
Cybercrime exercise

Quiz
•
7th Grade - University
20 questions
CICT Quiz Bee: Battle of the Brains (Clinch Round)

Quiz
•
University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

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

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade
Discover more resources for Information Technology (IT)
10 questions
Would you rather...

Quiz
•
KG - University
20 questions
Definite and Indefinite Articles in Spanish (Avancemos)

Quiz
•
8th Grade - University
7 questions
Force and Motion

Interactive video
•
4th Grade - University
10 questions
The Constitution, the Articles, and Federalism Crash Course US History

Interactive video
•
11th Grade - University
7 questions
Figurative Language: Idioms, Similes, and Metaphors

Interactive video
•
4th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
16 questions
Water Modeling Activity

Lesson
•
11th Grade - University
10 questions
ACT English prep

Quiz
•
9th Grade - University