
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
NET102: Quiz No. 1
Quiz
•
University
20 questions
Prototyping Model in SDLC Quiz -SLT
Quiz
•
University
20 questions
Higher Admin Microsoft Word Advanced Features
Quiz
•
8th Grade - University
20 questions
บทที่ 3 เครือข่ายคอมพิวเตอร์และอินเทอร์เน็ตในโรงแรม
Quiz
•
University
20 questions
MS Excel
Quiz
•
11th Grade - University
20 questions
DSA (QUIZ 6) Hashing, Graphs, Advanced Graph Algorithms, and DP
Quiz
•
University
20 questions
RIDDLE_IT_OUT
Quiz
•
University
20 questions
Technology Tools
Quiz
•
University
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
Discover more resources for Information Technology (IT)
7 questions
How James Brown Invented Funk
Interactive video
•
10th Grade - University
5 questions
Helping Build the Internet: Valerie Thomas | Great Minds
Interactive video
•
11th Grade - University
12 questions
IREAD Week 4 - Review
Quiz
•
3rd Grade - University
23 questions
Subject Verb Agreement
Quiz
•
9th Grade - University
7 questions
Renewable and Nonrenewable Resources
Interactive video
•
4th Grade - University
19 questions
Review2-TEACHER
Quiz
•
University
15 questions
Pre2_STUDENT
Quiz
•
University
20 questions
Ch. 7 Quadrilateral Quiz Review
Quiz
•
KG - University