NEW
Font size
WorksheetsWorksheet: Basic C++ Conditionals and Operators
Total questions: 10
Worksheet time: 3mins
What is the output of this code? int a = 8, b = 3; if (a + b > 10) cout << "Yes"; else cout << "No";
Yes
No
11
Error
Which arithmetic operator is used to find the remainder?
+
%
/
*
What will the following code print? int x = 10, y = 5; if (x - y == 5) cout << "Correct"; else cout << "Wrong";
Correct
Wrong
5
Error
What is the value of result in the following?
int a = 7, b = 2;
int result = a * b;
9
14
5
2
Which comparison operator checks if two values are not equal?
!=
==
<
>=
Consider this code: int score = 80; if (score >= 90) cout << "Excellent"; else if (score >= 75) cout << "Good"; else cout << "Try Again"; What is printed?
Excellent
Good
Try Again
Error
Which code correctly checks if a number n is even?
if (n % 2 == 0)
if (n / 2 == 0)
if (n % 2 != 0)
if (n == 2)
What is the output of this code? int a = 4, b = 6; if (a > b) cout << "A is bigger"; else cout << "B is bigger";
A is bigger
B is bigger
10
Error
Which statement is correct for combining arithmetic and comparison?
if (x + y > 15)
if x + y > 15
if (x + y := 15)
if x + y => 15
Complete the logic: int marks = 65; if (marks >= 75) cout << "Passed"; else cout << "Failed"; If marks is 65, what is printed?
Passed
Failed
75
Error
