wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Daniyal

Total questions: 45

Worksheet time: 11hrs 10mins

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)

Comparison, logical, arithmetic

b)

Arithmetic, comparison, logical

c)

Logical, arithmetic, comparison

d)

Arithmetic, logical, comparison

4.

Precedence for Logical Operators

a)

OR, AND, NOT

b)

OR, NOT, AND

c)

NOT, AND, OR

d)

AND, OR, NOT

5.

What is an array?

a)

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.

b)

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

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 individually referenced by adding an index to a same identifier.

6.

Find the arithmetic operator

a)

x

b)

+

c)

+y

d)

&x

7.

5+9*3*3-4 > 10 (2+16-8/4 > 6 || (2<6 10>11))

a)

True

b)

False

8.

How many times the current loop will execute? for (int i = 0; i <= 5; i += 3);

a)

2 times

b)

3 times

c)

Never

d)

5 times

9.

There are two different ways to implement multi selections in C++ language. They are

a)

Else – if and switch case

b)

If… else and switch case

c)

Else if

d)

Not sure

10.

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

a)

True

b)

Nothing

c)

All of them

d)

False

11.

A two-dimensional array represents data in the form of table with rows and columns

a)

Nothing

b)

True

c)

False

d)

All of them

12.

Which statement of array is true?

a)

Int foo[5]={10,20,30};

b)

Int foo[]{10,20,30};

c)

Int foo[3]={10,20,30};

d)

Int foo[];

13.

What are strings?

a)

Strings are objects that represent sequences of characters

b)

Strings are objects that represent sequences of pointers

c)

Strings are objects that represent sequences of special words

d)

Strings are objects that represent sequences of structures

14.

In which data type we write text

a)

String

b)

Int

c)

Float

d)

double

15.

Choose the right syntax to define a function

a)

name [parameter1, parameter2]

b)

type (parameters)

c)

parameter1, parameter2(name)

d)

type name(parameter1, parameter2)

16.

A function can return more than one value

a)

True

b)

False

17.

What are the three steps in using a function?

a)

Definition, invocation, argument.

b)

Prototype, argument, signature.

c)

Definition, prototype, invocation.

18.

The factorial function.

a)

if(n-1){return n*factorial(n-1);} else {return 1;}

b)

n!=n*(n+1)!

c)

n!=n-(n-1)! And 1!=1

d)

n!=n/(n-1)! And 1!=1

19.

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

a)

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

b)

Void mpg(){}

c)

Double mpg(double a, double b)

d)

Double mpg(int a, double b)

20.

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.

21.

Which of the following are themselves a collection of different data types?

a)

String

b)

Structure

c)

Char

d)

Integer

22.

The data elements in structure are also known as what?

a)

Objects

b)

Data

c)

Members

d)

None of the above

23.

What will be used when terminating a structure?

a)

Brackets

b)

Colon

c)

Semicolon

d)

Dot

24.

Which of the following is address of operator represented by?

a)

$

b)

#

c)

&

d)

@

25.

Pointers may be compared by using relational operators

a)

True

b)

False

26.

What will be used between the object name and the member name?

a)

Dot

b)

Semicolon

c)

Colon

d)

Anything

27.

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

a)

Ifstream

b)

Ofstream

c)

Iostream

d)

Fstream

28.

Which stream class is only used to read files?

a)

Ifstream

b)

Ofstream

c)

Iostream

d)

Fstream

29.

Which of the following shows the correct syntax for if statement?

a)

If expression

b)

If(expression)

c)

If{expression}

d)

Expression if

30.

When does the code block following while(x<100) execute?

a)

While it wishes

b)

When x is less than one hundred

c)

When x is greater than one hundred

d)

When x is equal to one hundred

31.

Which of the following properly declares struct?

a)

struct {int a;}

b)

struct a_struct {int a;}

c)

struct a_struct int a;

d)

struct a_struct {int a;};

32.

Which of the following properly declares a variable of struct foo?

a)

struct foo;

b)

foo var;

c)

foo;

d)

int foo;

33.

Which of the following correctly declares an array?

a)

int anarray[10];

b)

int anarray;

c)

anarray{10};

d)

array anarray[10];

34.

What is the difference between array and structure?

a)

Only on their declaration

b)

No difference

c)

Structure can include members of different data types

d)

Arrays can include only integers

35.

There is an array with 29 elements, what is the index number of the last array element?

a)

29

b)

0

c)

28

d)

Array does not have element’s index

36.

What will output from the following program

a)

Hello will print three times

b)

Hello will print once

c)

Hello will print not be printed three times

d)

Compile error

37.

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

a)

2 times

b)

3 times

c)

5 times

d)

infinitely

38.

How many times the current loop will execute<xmp>for (int i = 0; i <= 10; i++);</xmp>?

a)

11 times

b)

Never

c)

10 times

d)

0

39.

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

40.

What is the output from the following program

a)

3^4 is 81

b)

3^4 is 80

c)

3^4 is 12

d)

43

41.

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)

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

c)

intalua(int x, int y)

d)

intfunct(int x, int y, int z)

42.

Write correct function prototype for the function ‘intToDouble’ that takes an integer argument ‘number’, and returns a double value.

a)

double intToDouble(int number);

b)

float intToDouble(int number);

c)

double intToDouble(double number);

d)

intintToDouble(number);

43.

The OR (||) operator:

a)

Has higher precedence that AND (&&) operator

b)

Stops evaluation upon finding one condition to be true

c)

Associates from right to left

d)

True if all conditions are true

44.

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

a)

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

b)

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

c)

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

d)

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

45.

Which conversion is not possible?

a)

int to float

b)

float to int

c)

char to float

d)

All are possible