wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

ввп,

Total questions: 35

Worksheet time: 18mins

Name
Class
Date
1.

Which of the following operators is used for input in C++?

a)

abs

b)

cin

c)

sqrt

d)

cos

e)

cout

2.

the value 25.17 can be represented using which data type?

a)

integer

b)

bool

c)

double

d)

void

3.

What type of statement is cin >> number;?

a)

output statement

b)

input statement

c)

declaration of variable

4.

The value 12.5 can be represented using what type of data?

a)

float

b)

integer

c)

bool

d)
  • void

5.

In C++, this statement terminates the loop when it is encountered?

a)

continue

b)

break

c)
  • &&

6.

What is an array?

a)

An array is a series of elements of the same type placed in non-contiguous memory locations

b)
  • An array is a series of elements of the same type in contiguous memory locations

c)
  • None of the mentioned

d)
  • An array is a series of element

7.

Which of the following statements is true?

a)

The value of variable a is assigned to variable b and the value of variable b is assigned to variable a.

b)

The value of b is assigned to variable a and the later changes on variable b will effect the value of variable a.

c)

The variable a and the variable b are equal.

d)

The value of b is assigned to variable a but the later changes on variable b will not effect the value of variable a.

8.

Which of the following is selection statement in C++?

a)

int

b)

bool

c)
  • do

d)
  • cin

e)

switch

9.

Elements in Two-Dimensional arrays are accessed using ______.

a)

the row indexes and column indexes

b)

the column indexes

c)

the type of element

d)

the row indexes

10.

This statement breaks one iteration (in the loop), if a specified condition occurs

a)

continue

b)
  • &&

c)

break

11.

the general form of declaring a two-dimensional array?

a)
  • array_name[size1][size2];

b)
  • data_type array_name[number of rows][number of columns];

c)
  • data_type array_name[size];

d)
  1. array_name data_type[a][b];

12.

Which of the following is the correct operator to compare two variables?

a)

Equal

b)
  • +=

c)
  • ||

d)
  • &&

e)
  • ==

13.

Which is NOT a loop structure in C++?

a)

do while

b)

repeat until

c)
  • for

d)
  • do

14.

Looping in a program means...

a)

to repeat the specified lines of code

b)

jumping to the specified branch of program

c)

All of them

15.

How many times the current loop will execute: for (int i = 1; i <= 4; i += 3);?

a)

2

b)

3

c)

4

d)

1

e)

0

16.

Which should be included to work with files?

a)

cmath

b)

string

c)

fstream

17.

Which of the following properly declares a variable var of structure foo?

a)
  • foo var;

b)
  • intstruct foo;

c)
  • var foo strust;

d)
  • Struct foo;

18.

What is structure?

a)
  • a group of data elements together with some name.

b)
  • a group of data elements grouped together under two names.

c)
  • a set of some elements grouped together under value.

d)
  1. a group of data elements grouped together under one name.

19.

How many elements does this two-dimensional array have: int arraytwo[3][4];?

a)

12

b)

7

c)

0

d)

4

e)

3

20.

______ is used to insert characters in string at specified position.

a)
  • insert()

b)

cin

c)
  • getline()

d)
  • cout

21.

Observe the following function declaration and choose the best answer: int divide (int a, int b = 2)

a)
  • Variable a and b are of int type and the initial value of both variables is 2

b)
  • Variable b will have value 2 if not specified when calling function

c)
  • Variable b is international scope and will have value 2

d)
  1. Variable b is of integer type and will always have value 2

22.

The return type of the function prototype float func(char x, float v, double t); is:

a)
  • int

b)
  • float

c)

double

d)

char

e)

string

23.

Why do we need fstream class?

a)
  • To work with files.

b)
  • To work with mathematical functions.

c)
  1. To work with strings.

24.

What will be used when terminating a structure?

a)

Brackets

b)

Dot

c)

Semicolon

d)

Colon

25.

Write the correct function definition, where function 'alua' that takes three integers, x, y and z, and returns an integer?

a)
  • double alua(int x, int y, int z)

b)
  • intfunct (int x, int y, int z)

c)
  • char alua(int x, int y, int z)

d)
  • int alua (int x, int y, int z)

26.

By default, all the files are opened in __________ mode.

a)

binary

b)

text

27.

Which of the following gives the memory address of a pointer a?

a)
  • *a;

b)
  • a[0];

c)
  • &a;

d)
  • address(a);

28.

We declare a function with ______ if it does not have any return type.

a)
  • void

b)
  • int

c)

float

d)

double

e)

bool

29.

Choose the right option:

string* x; string y;

a)
  • x is a pointer to a string, y is a string

b)

y is a pointer to a string, x is a string

c)

both x and y are pointer to string types

30.

The return type of the function prototype int func(char x, float v, double t); is:

a)

int

b)

float

c)

bool

d)

double

e)

char

31.

What value will be in the variable b after executing the following code: b = 5; a = b++;?

a)

4

b)

6

c)

0

d)

5

e)

3

32.

Which stream class is used to both read and write on files?

a)

ifstream

b)

iostream

c)

ofstream

d)

fstream

33.

Pointers may be compared by using relational operators.

a)

False

b)

True

34.

What is the correct value to return to the operating system upon the successful completion of a program?

a)
  • -1

b)

20

c)

10

d)

0

e)

1

35.

What is the difference between array and structure?

a)
  • Arrays can include only integers

b)
  • Structure can include members of different data types

c)
  1. No difference