Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C++ Quiz

Total questions: 20

Worksheet time: 18mins

Name
Class
Date
1.

What is the output of this code?

int x = 8;

// x = 3;

cout<<x<<endl;

a)

3

b)

8

c)

error

d)

x

2.

What is the type of the temp variable?

var temp = 14.55;

a)

Double

b)

Boolean

c)

Integer

d)

String

3.

What is the alternative for x = x + 5?

a)

x += 5;

b)

x -= 4;

c)

x = y + 5;

d)

x=+5

4.

What is void?

a)

A statement that returns a value

b)

A statement that doesn't return a value

c)

A function that return a value

d)

A function that doesn't return a value

5.

iostream

a)

Displays output from the screen and input from the keyboard

b)

Has all the math equations

c)

Counts the time

d)

Checks if the code has a function

6.

Switch Statement

a)

Is a statement with a set of conditions called cases

b)

Is a case

c)

Is a condition with no cases

d)

Is a boolean statement

7.

Loops in C Language are implemented using.?

a)

While

b)

For

c)

Do While

d)

All the above

8.

What is the way to suddenly come out of or Quit any Loop in C Language.?

a)

continue; statement

b)

break; statement

c)

leave; statement

d)

quit; statement

9.

What is the only function that all C++ programs must contain?

a)

main ()

b)

void ()

c)

system ()

d)

start ()

10.

Which operators are used in C++?

a)

==

b)

+=

c)

**

d)

++

11.

AND operator in C++ is written as:

a)

&&

b)

&

c)

||

d)

AND

12.

Where is the mistake?

a)

% must be replaced with /

b)

= must be replaced with ==

c)

3 must be replaced with 2

d)

There is no mistake

13.

What are the mistakes in this code?

a)

x must be <=10 instead of x<100

b)

The function is log(x) not log10(x)

c)

float sum must be used instead of int sum

d)

cin>>x

is not needed

e)

Math library is not needed

14.

Which of the following loops goes to infinity?

a)

for (int i=0 ; ; )

b)

for (int i=0 ; ; i=∞)

c)

for (int i=0 ; i<=1000000000000000000 ; i++)

d)

for (int i=0 ; ; i++)

15.

Which loop executes the statements at least one time before evaluating the expression?

a)

do-while loop

b)

for loop

c)

while loop

d)

none of the above

16.

What will be the output of this code?

for (int n=10; n>0; n- -)

{

                      if (n==4) continue;

                        cout<<n<<endl;

 }

a)

10,9,8,7,6,4,3,2,1

b)

10,9,8,7,6,5,4,3,2,1

c)

10,9,8,7,6,5,3,2,1

d)

10,9,8,7,6,5,4,3,2,1,0

17.

((4==4) && (3>6))   returns:

a)

True

b)

False

18.

cout<<floor(12.5)<<endl;

prints:

a)

12

b)

13

c)

12.5

d)

None of the above

19.

scope of variable (age) is:

a)

a local variable

b)

a global variable

c)

integer

d)

18

20.

C++ is a

a)

high-level language

b)

low-level language