wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Worksheet: Basic C++ Conditionals and Operators

Total questions: 10

Worksheet time: 3mins

Name
Class
Date
1.

What is the output of this code? int a = 8, b = 3; if (a + b > 10) cout << "Yes"; else cout << "No";

a)

Yes

b)

No

c)

11

d)

Error

2.

Which arithmetic operator is used to find the remainder?

a)

+

b)

%

c)

/

d)

*

3.

What will the following code print? int x = 10, y = 5; if (x - y == 5) cout << "Correct"; else cout << "Wrong";

a)

Correct

b)

Wrong

c)

5

d)

Error

4.

What is the value of result in the following?

int a = 7, b = 2;

int result = a * b;

a)

9

b)

14

c)

5

d)

2

5.

Which comparison operator checks if two values are not equal?

a)

!=

b)

==

c)

<

d)

>=

6.

Consider this code: int score = 80; if (score >= 90) cout << "Excellent"; else if (score >= 75) cout << "Good"; else cout << "Try Again"; What is printed?

a)

Excellent

b)

Good

c)

Try Again

d)

Error

7.

Which code correctly checks if a number n is even?

a)

if (n % 2 == 0)

b)

if (n / 2 == 0)

c)

if (n % 2 != 0)

d)

if (n == 2)

8.

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)

A is bigger

b)

B is bigger

c)

10

d)

Error

9.

Which statement is correct for combining arithmetic and comparison?

a)

if (x + y > 15)

b)

if x + y > 15

c)

if (x + y := 15)

d)

if x + y => 15

10.

Complete the logic: int marks = 65; if (marks >= 75) cout << "Passed"; else cout << "Failed"; If marks is 65, what is printed?

a)

Passed

b)

Failed

c)

75

d)

Error