wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Chapter6-2

Total questions: 20

Worksheet time: 15mins

Name
Class
Date
1.

What are the methods used to pass parameters to a function in C++?

a)

Call by memory

b)

Call by reference

c)

Call by duplicating the argument

d)

Call by value

2.

In C++ What is the symbol used to tell the compiler that you are sending a parameters to a function by reference?.

a)

&&

b)

@

c)

*

d)

&

3.

In C++ when sending parameters by reference the & is placed.

a)

&<Data Type>

b)

<Data Type> & <Variable Name>

c)

<Data Type> <Variable Name>&

d)

<Data Type> <Constant Name>&

4.

In C++ When passing parameters by reference to a function, you are passing:

a)

A copy of the value in the calling function.

b)

The value of the parameters in the calling function

c)

The memory address of the variable in the calling function

d)

None of the above.

5.

In C++, If you need to send a value to a function by using parameters, and you do not need to return anything from the function, what type of call will you use:

a)

Call by Value

b)

Call by Reference

c)

Call by Cellular phone

d)

A void call

6.

In C++, if a function receives a parameter by reference and it changes the value, what happens?.

a)

Nothing

b)

The value of the variable in the calling function will be changed as well

c)

You will get a compiler error

d)

Unlimited loop

7.

select the correct syntax:

a)

void func1 ( int& val1)

{

.......

}

b)

void func1 ( &int val1)

{

.......

}

c)

void& func1 ( int val1)

{

.......

}

d)

&void func1 ( int val1)

{

.......

}

8.

int &x; this syntax is used when...

a)

x is passed by value

b)

x is passed by reference

c)

x is declare outside functions

d)

None of them

9.

Which statement is correct about passing by value parameters?

a)

It cannot change the actual parameter value

b)

It can change the actual parameter value

c)

Parameter is always in read-write mode

d)

None of them

10.

___________ is the identifier used in a method to stand for the value that is passed into the method by a caller

a)

formal parameter

b)

actual parameter

c)

functions

d)

none of them

11.

What is the main purpose of functions in C++?

a)

To execute loops faster

b)

To reduce code redundancy and improve reusability

c)

To replace the main() function

d)

To speed up compilation

12.

Which keyword defines a function that does not return a value?

a)

int

b)

return

c)

void

d)

float

13.

How do you call a function in C++?

a)

functionName;

b)

functionName()

c)

call functionName();

d)

define functionName();

14.

What is required in a function declaration?

a)

Function name and parameters

b)

Only the function body

c)

Function name, return type, and parameters (if any)

d)

Only the return type

15.

What will happen if a function is declared but not called?

a)

It will cause a compilation error

b)

It will execute automatically

c)

Nothing will happen

d)

The program will crash

16.

Which of the following statements about function parameters is true?

a)

A function can only have one parameter

b)

Parameters are mandatory in all functions

c)

Parameters act as variables inside the function

d)

Parameters must be initialized in the function declaration

17.

What is "pass by reference" in functions?

a)

Passing values by copying them

b)

Allowing a function to modify the original variable

c)

Passing only integer values

d)

Calling a function multiple times

18.

Which function type returns a value?

a)

void function

b)

Function with no parameters

c)

Function with a return type

d)

Function with default parameters

19.

Which statement about the return keyword is correct?

a)

It must always be used in functions

b)

It ends function execution and sends a value back

c)

It only works with int functions

d)

It can only be used once per function

20.

What is the output of the following code: void update(int &x) { x += 10; } int num = 5; update(num); cout << num;

a)

5

b)

10

c)

15

d)

Compilation error