Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

c++ 1

Total questions: 50

Worksheet time: 25mins

Name
Class
Date
1.

   Specify the types of operator

a)

Logical, Bitwise, Arithmetic, Relational

b)

Mathematical, Bitwise, Arithmetic, Relational

c)

Assignment, Bitwise, Arithmetic, Relational

d)

Logical, Bitwise, Assignment, Relational

2.

Logical operators always evaluated from

a)

Left to right

b)

No difference

c)

Not sure

d)

Right to left

3.

When an equation uses more than one type of operator then the order of precedence has to be established with the different types of operators:

a)

Arithmetic, comparison, logical

b)

Comparison, logical, arithmetic

c)

Logical, arithmetic, comparison

d)

Arithmetic, logical, comparison

4.

Precedence for Logical Operators

a)

NOT, AND, OR

b)

OR, AND, NOT

c)

OR, NOT, AND

d)

AND, OR, NOT

5.

What is an array?

a)

An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by adding an index to a unique identifier

b)

An array is a series of elements of the different type placed in contiguous memory locations that can be individually referenced by adding an index to a unique.

c)

An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by multiplying an index to a unique identifier

d)

An array is a series of elements of the same type placed in contiguous memory locations that can be

o individually referenced by adding an index to a same identifier.

6.

When an array is partially initialized, the rest of its elements will automatically be set to zero

a)

False

b)

True

c)

Nothing

d)

All of them

7.

The whole array can be passed to a function. However, it can't be changed by the code in that function

a)

False

b)

All of them

c)

Nothing

d)

True

8.

What are the three steps in using a function?

a)

Definition, prototype, invocation

b)

Prototype, argument, signature

c)

Definition, invocation, argument

9.

write mpg() function prototype, that takes two type double arguments and returns a double

a)

Double mpg(double a, double b)

b)

Void mpg(){}

c)

Float mpg(int a){ float b = 1; return b;}

d)

Double mpg(int a, double b)

10.

What is data structure?

a)

is a group of data elements grouped together under one name

b)

is a group of data elements grouped together under two names.

c)

is a set of some elements grouped together under value

d)

is a group of data elements together with some name.

11.

The data elements in structure are also known as what?

a)

Members

b)

Data

c)

Objects

d)

None of the above

12.

What will be used when terminating a structure?

a)

Semicolon

b)

Colon

c)

Brackets

d)

Dot

13.

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

a)

Fstream

b)

Iostream

c)

Ofstream

d)

Ifstream

14.

Which stream class is only used to read files

a)

Ifstream

b)

Ofstream

c)

Iostream

d)

Fstream

15.

What is the difference between array and structure?

a)

Structure can include members of different data types

b)

No difference

c)

Only on their declaration

d)

Arrays can include only integers

16.

What is the output from the following program code?

a)

10 10 10 10 10

b)

11 11 11 11 11

c)

10

d)

0 1 2 3 4

e)

Error

17.

The OR (||) operator:

a)

Stops evaluation upon finding one condition to be true

b)

Has higher precedence that AND (&&) operator

c)

True if all conditions are true

d)

Associates from right to left

18.

Which of the following for headers is not valid for C++ code?

a)

for (integer i =0; j<10; i++);

b)

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

c)

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

d)

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

e)

all

19.

There might be functions with the same name, but different arguments. The function called is the one whose arguments match the invocation. What is this mean?

a)

Function overloading

b)

Function overprocessing

c)

Argument type error

d)

Argument dispatch error

20.

Which of the following cannot be used to create a random numbers?

a)

structures

b)

float

c)

int

d)

none of the mentioned

21.

Please evaluate !(1 && !(0 || 1)).

a)

True

b)

False

c)

Unevaluatable

d)

Not sure

22.

What is the final value of x when the code int x; for(x=0; x<50; x++) {} is run?

a)

50

b)

10

c)

0

d)

51

23.

How many times is a do while loop guaranteed to loop?

a)

Infinitely

b)

0

c)

1

d)

Variable

24.

What is the output of the following code?

a)

value

b)

77.5

c)

Float

d)

Variable

25.

Which of the following is a valid function call (assuming the function exists)?

a)

funct();

b)

funct;

c)

funct x, y;

d)

struct funct();

26.

Which of the following is a complete function?

a)

int funct(int x) {return x=x+1;}

b)

int funct();

c)

void funct[int] {cout&tl;<"Hello"}

d)

void funct{x} {cout<<"Hello"}

27.

Which of the following is required to avoid falling through from one case to the next?

a)

Break;

b)

End;

c)

Stop;

d)

A semicolon;

28.

Which of the following is the proper declaration of a pointer?

a)

int *x;

b)

ptr x;

c)

int &x;

d)

int x;

29.

Which of the following gives the memory address of integer variable a?

a)

&a;

b)

*a;

c)

a;

d)

address(a);

30.

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

a)

&a;

b)

*a;

c)

a;

d)

address(a);

31.

Which of the following gives the value stored at the address pointed to by the pointer a?

a)

a;

b)

val(a);

c)

*a;

d)

&a;

32.

Which of the following gives the value stored at the address pointed to by the pointer ptr?

a)

ptr;

b)

val(ptr);

c)

*ptr;

d)

&ptr;

33.

Which of the following accesses a variable in structure b?

a)

b.var;

b)

b->var;

c)

b-var;

d)

b>var;

34.

Which of the following accesses a variable in structure mystruct?

a)

mystruct.var;

b)

mystruct ->var;

c)

mystruct -var;

d)

mystruct >var;

35.

Which of the following correctly accesses the seventh element stored in diana, an array with 100 elements?

a)

diana[6]

b)

diana[7]

c)

diana(7)

d)

diana;

36.

What is the correct way to write the condition y < x < z?

a)

((y < x) && (x < z))

b)

((y < x) || (x < z))

c)

((y < x) & (x < z))

d)

((y < x) AN (x < z))

37.

The value 132.54 can represented using which data type?

a)

Double

b)

Void

c)

Integer

d)

Bool

38.

In an assignment statement “ a=b; ” which of the following statement is true?

a)

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

b)

The variable a and the variable b are equal.

c)

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

39.

The difference between while structure and do structure for looping is

a)

In while structure condition is tested before executing statements inside loop whereas in do structure condition is tested before repeating the statements inside loop

b)

The do structure decides whether to start the loop code or not whereas while statement decides whether to repeat the code or not

c)

In do structure the condition is tested at the beginning of first iteration

d)

In while statement the condition is tested at the end of first iteration

40.

A function that calls itself for its processing is known as

a)

Inline Function

b)

Nested Function

c)

Overloaded Function

d)

Recursive Function

41.

The keyword endl

a)

Ends current line and starts a new line in cout statement

b)

Ends the line in program. There can be no statements after endl

c)

Ends the output in cout statement

d)

Ends the execution of program where it is written

42.

Strings are character arrays. The last index of it contains the nullterminated character

a)

\0

b)

\n

c)

\t

d)

\1

43.

Variables inside parenthesis of functions declarations have _____ level access

a)

Local

b)

Global

c)

Module

d)

Universal

44.

Array indexing always starts with the number

a)

0

b)

1

c)

-1

d)

10

45.

Which of the following accesses a variable in structure st1?

a)

st1.var;

b)

st1->var;

c)

st1-var;

d)

st1>var;

46.

Which looping process is best used when the number of iterations is known?

a)

For

b)

While

c)

Do-while

d)

Nothing

47.

If there is more than one statement in the block of a for loop, which of the following must be placed at the beginning and the ending of the loop block?

a)

parentheses ( )

b)

braces { }

c)

brackets [ ]

d)

arrows < >

48.

A memory address is…

a)

where a variable is stored.

b)

where a variable is defined.

c)

where a variable is declares.

d)

where a variable is print out.

49.

The set of instructions that a computer will follow is known as..

a)

program

b)

variable

c)

computer

d)

brackets

50.

cin >> number; is

a)

an output statement

b)

a colon

c)

a variable

d)

an input statement