wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CPP Mid Term SPOT test

Total questions: 25

Worksheet time: 20mins

Name
Class
Date
1.

Any CPU of computer can understand

a)

High level programming language

b)

machine language

c)

assembly language

d)

English language

2.

In Cpp source code 72, 'z', “3.141 * r”, 3.987 are example of __________

a)

Variable

b)

Strings

c)

Literals

d)

not possible to categories into one option given below

3.

What will be the output of the following Cpp program

a)

2

b)

4

c)

8

d)

program will give error while compiling

4.

Cpp Compiler converts source code in

a)

.cpp file

b)

.obj file

c)

.exe file

d)

.lnk file

5.

What value will get stored in x and n when the part of Cpp code given below get executed

int x , y = 3;

float n, m = 1.5;

x = y*m;

n = x * m;

a)

x = 4 and n = 6

b)

x= 4 and n = 6.0

c)

x = 4.5 and n = 6.75

d)

x = 5 and n = 7.5

6.

Directives are translated by the

a)

Pre-processor

b)

Compiler

c)

Linker

d)

Editor

7.

What will the result of 'num' variable after execution of the following statements?

int num = 58;

num % = 11;

a)

3

b)

5

c)

8

d)

11

8.

What will the result of num1 variable after execution of the following statements?

int j = 1, num1 = 4;

while (++j <= 10)

{

num1++;

}

a)

11

b)

12

c)

13

d)

14

9.

What output is produced by the following segment of code:


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

cout << i << " ";

a)

0 1 2 3 4 5 6 7 8 9 10

b)

0 1 2 3 4 5 6 7 8 9

c)

1 2 3 4 5 6 7 8 9 10

d)

1 2 3 4 5 6 7 8 9

e)

Infinite Loop

10.

True/False: For Loops can never be an infinite loop.

a)

True

b)

False

11.

How many times will the shown for loop execute?

a)

0

b)

9

c)

10

d)

11

12.

What does <= mean?

a)

less than

b)

greater than

c)

less than or equal to

d)

greater than or equal to

13.

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

a)

cout()

b)

system()

c)

main()

d)

program()

14.

Which of the following is a correct comment?

a)

*/ Comments */

b)

** Comment **

c)

/* Comment */

d)

{ Comment }

15.

Which command moves the shown text to the next line?

a)

\t

b)

\n

c)

\r

d)

/n

16.

After running the following code, what will be the value of x?

y = 3;

x = 5 * (++y);

a)

15

b)

5

c)

15

d)

20

17.

Do while loops

a)

Runs a statement once

b)

Runs a statement twice

c)

Runs a statement multiple times or not within a boolean condition

d)

Doesn't run at all

18.

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

19.

Cpp Compiler converts source code in

a)

.cpp file

b)

.obj file

c)

.exe file

d)

.lnk file

20.

What is the difference when allocating the following memory?

int array1[15];

int array2[3][5];

a)

array1 is larger

b)

array2 is larger

c)

The size allocated is the same

21.

Fill in the blank to make the variable num a constant.


_______int num=2;

a)

con

b)

constant

c)

const

d)

constans

22.

Fill in the missing parentheses to have x equal 15.

int x =__2 + 3__* 3;

Console.WriteLine(x);

a)

(....)

b)

{.....}

c)

<....>

d)

|.....|

23.

What is the alternative for x = x + 5?

a)

x += 5;

b)

x -= 4;

c)

x = y + 5;

d)

x=+5

24.

Evaluate the following expressions to true or false


3!=4-1

a)

true

b)

False

25.

Evaluate the following expressions to true or false

5+1==6 || 8-1>4

a)

True

b)

False