wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

C++ Programming Quiz

Total questions: 42

Worksheet time: 21mins

Name
Class
Date
1.

Which class should be included to work with files?

a)

b)

c)

d)

2.

Which of the following is the valid array declaration?

a)

int arr(10);

b)

int arr[10];

c)

array int[10];

d)

int [10] arr;

3.

If the type specifier of parameters of a function is followed by &, that function call is…

a)

Call by value

b)

Call by pointer

c)

Call by reference

d)

Call by address

4.

Which gives the memory address of a pointer pt1?

a)

*pt1

b)

&pt1

c)

pt1

d)

**pt1

5.

Which libraries should be included to get string in a file?

a)

b)

c)

d)

and

6.

How to implement array of chars with 10 elements?

a)

char a;

b)

char a(10);

c)

char a[10];

d)

string a[10];

7.

How to get whole string in one line (command line)?

a)

cin >> str;

b)

gets()

c)

getline(cin, str);

d)

scanf()

8.

How to get whole string in one line (in file)?

a)

cin >>

b)

getline(file, str);

c)

file >> str;

d)

read()

9.

Why do we need library ?

a)

Console I/O

b)

String handling

c)

File handling

d)

Memory allocation

10.

What does this mean: int (*fp)(char*) ?

a)

Pointer to int

b)

Function returning pointer

c)

Pointer to function

d)

Array of functions

11.

Operator used for dereferencing is

a)

&

b)

*

c)

->

d)

.

12.

Choose the right option: string* x; string y;

a)

Both pointers

b)

x pointer, y variable

c)

x variable, y pointer

d)

Both variables

13.

Mandatory parts in function declaration are

a)

Function name

b)

Return type

c)

Parameters

d)

Return type and function name

14.

Which is used to terminate function declaration?

a)

:

b)

.

c)

;

d)

}

15.

Operator used for input stream is

a)

<<

b)

>>

c)

<>

d)

=

16.

Which correctly declares an array?

a)

int a[] = 10;

b)

int a[10];

c)

int a(10);

d)

array a[10];

17.

Index number of last element of array with 9 elements

a)

9

b)

1

c)

8

d)

0

18.

What is an array?

a)

Single variable

b)

Collection of different types

c)

Collection of same type elements

d)

Pointer

19.

Which accesses the 7th element of array a?

a)

a[7]

b)

a[6]

c)

a(7)

d)

a[8]

20.

Constants are also called as

a)

Variables

b)

Literals

c)

Identifiers

d)

Keywords

21.

Parts of literal constants are

a)

Integer only

b)

Integer and float

c)

Numeric, character, string

d)

Boolean only

22.

How constants are declared?

a)

int x;

b)

const int x;

c)

constant int x;

d)

final x;

23.

Inline function is expanded inline at

a)

Compile time

b)

Run time

c)

Link time

d)

Execution time

24.

If argument is declared as const, then

a)

It can be modified

b)

It cannot be modified

c)

It must be global

d)

It must be static

25.

C++ appends what at end of string literal?

a)

\n

b)

\0

c)

EOF

d)

Space

26.

Pointer P stores address of value. Which prints value?

a)

P

b)

&P

c)

*P

d)

**P

27.

Function calling itself is called

a)

Inline

b)

Overloaded

c)

Recursive

d)

Virtual

28.

int divide(int a, int b = 2) means

a)

Function overloading

b)

Default argument

c)

Inline function

d)

Recursion

29.

Variables inside parentheses of function have

a)

Global access

b)

Static access

c)

Local access

d)

Public access

30.

Last index of string contains

a)

Space

b)

Newline

c)

\0

d)

Last character

31.

const int pathwidth = 100; means

a)

Variable

b)

Pointer

c)

Constant integer

d)

Macro

32.

By default files are opened in

a)

Write mode

b)

Append mode

c)

Read mode

d)

Binary mode

33.

What punctuation ends most C++ lines?

a)

.

b)

:

c)

;

d)

,

34.

Which is not a correct variable type?

a)

int

b)

float

c)

real

d)

char

35.

Unique function where execution starts

a)

start()

b)

main()

c)

begin()

d)

init()

36.

Which cannot be used in identifiers?

a)

Letter

b)

Digit

c)

Underscore

d)

Space

37.

Which is not a valid escape code?

a)

\n

b)

\t

c)

\z

d)

\0

38.

To increase value of c by one, which is wrong?

a)

c++

b)

++c

c)

c = c + 1

d)

c + 1

39.

b=3; a=b++; result is

a)

a=4, b=4

b)

a=3, b=4

c)

a=4, b=3

d)

a=3, b=3

40.

Result of relational operation is always

a)

Integer

b)

Float

c)

Boolean

d)

Character

41.

Looping means

a)

Program termination

b)

Repetition of statements

c)

Function call

d)

Conditional check

42.

If parameter uses &, function call is

a)

Call by value

b)

Call by pointer

c)

Call by reference

d)

Call by copy