wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Algo

Total questions: 56

Worksheet time: 28mins

Name
Class
Date
1.

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.

2.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)

Comparison, logical, arithmetic

b)

Arithmetic, comparison, logical

c)

Logical, arithmetic, comparison

d)

Arithmetic, logical, comparison

3.

Logical operators always evaluated from

a)

 Right to left

b)

 Not sure

c)

Left to right

d)

No difference

4.

4. Precedence for Logical Operators

a)

OR, AND, NOT

b)

NOT, AND, OR

c)

AND, ORNOT

d)

OR, NOT, AND

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

c)

be individually referenced by adding an index to a unique.

d)

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

6.

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

a)

All of them

b)

Nothing

c)

False

d)

True

7.

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

a)

 All of them

b)

False

c)

Nothing

d)

True

8.

What are the three steps in using a function?

a)

Definition, prototype, invocation

b)

Definition, invocation, argument

c)

Prototype, argument, signature

9.

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)

Data

b)

 None of the above

c)

Members

d)

Objects

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)

Ifstream

b)

Ofstream

c)

Fstream

d)

Iostream

14.

Which stream class is only used to read files

a)

Ofstream

b)

Ifstream

c)

Iostream

d)

Fstream

15.

What is the difference between array and structure?

a)

No difference

b)

Only on their declaration

c)

Structure can include members of different data types

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)

0 1 2 3 4

d)

10

17.

The OR (||) operator

a)

Has higher precedence that AND (&&) operator

b)

Stops evaluation upon finding one condition to be true

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 (int i = 0; i<7; i++)

b)

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

c)

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

d)

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

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.

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

a)

structures

b)

float

c)

int

d)

o none of the mentioned

21.

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

a)

True

b)

False

c)

o Unevaluatable

d)

o Not sure

22.

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

a)

10

b)

50

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 x, y;

c)

funct();

d)

struct funct();

26.

26. Which of the following is a complete function?

a)

int funct();

b)

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

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)

End;

b)

Break

c)

Stop

d)

A semicolon

28.

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

a)

int x;

b)

int &x;

c)

int *x;

d)

ptr 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.

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)

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

d)

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

37.

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 variable a and the variable b are equal.

b)

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

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 statement the condition is tested at the end of first iteration

b)

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

c)

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

d)

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

40.

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 the execution of program where it is written

b)

Ends the output in cout statement

c)

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

d)

Ends current line and starts a new line in coutstatement

42.

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

a)

\n

b)

\t

c)

 \0

d)

\1

43.

43. Variables inside parenthesis of functions declarations have _____ level access

a)

Local

b)

Global

c)

Module

d)

Universal

44.

44. Array indexing always starts with the number

a)

0

b)

1

c)

-1

d)

10

45.

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 forloop, 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

51.

51. cout << "How many items would you want?\n"; is

a)

an output statement

b)

 a colon

c)

 a variable

d)

an input statement

52.

int number; is

a)

an output statement

b)

a variable declaration

c)

 a variable

d)

an input statement

53.

If x is 0, what is the value of (!x == 0)?

a)

True

b)

False

c)

2

d)

15

54.

How to create array with n integers?

a)

int n; cin >> n; int a = new# int[n];

b)

int n; cin >> n; int& a; a = new int[n];

c)

int n; cin >> n; int* a; a = new int[n];

d)

int n; cin >> n; int a; a = new% int[n];

55.

Which class should be included to work with files?

a)

iostream

b)

string

c)

cmath

d)

fstream

56.

Which of the following is the output from the following C++ code?

a)

15 14 13 12 11 10

b)

15 14 13 12 11 10 9

c)

9

d)

15