wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Functions in C++

Total questions: 20

Worksheet time: 8mins

Name
Class
Date
1.

The functions are also called as

(a)  

2.

what is a function?

a)

Function is a block of statements that perform some specific task.

b)

Function is the fundamental modular unit. A function is usually designed to perform a specific task.

c)

Function is a block of code that performs a specific task. It has a name and it is reusable.

d)

All of the above

3.

The statement used to invoke a function is called as

(a)  

4.

For the function specified as: int cal(int, float);, the return statement will :

a)

return the value

b)

does not return the value

c)

returns multiple values

d)

returns 0

5.

Use of functions

a)

Helps to avoid repeating a set of statements many times.

b)

Enhances the logical clarity of the program.

c)

Helps to avoid repeated programming across programs.

d)

Makes the debugging task easier.

e)

All of the above

6.

What are types of Functions in C++ Language.?

a)

A) Library Functions

b)

B) User Defined Functions

c)

C) Both Library and User Defined

d)

D) None of the above

7.

The (a)   type of variable has scope throughout the program

8.

The function is executed when it is

a)

prototyped

b)

declared

c)

defined

d)

called

9.

What is the output for the following?

#include<iostream.h>

int x;

void main()

{

m();

cout<< x;

x++;

m();

cout<<x;

}

void m()

{

x = 4;

}

a)

4 0

b)

5 4

c)

4 5

d)

4 4

10.

x= display(x,y);

what type of function is this statement belong to?

a)

with arguments and no return value

b)

without arguments and return value

c)

with arguments and with return value

d)

without arguments and no return value

11.

What is the default return type if it is not specified in function definition?

a)

void

b)

int

c)

double

d)

short int

12.

A function which calls itself is called a ___ function.

a)

Self Function

b)

Auto Function

c)

Recursive Function

d)

Static Function

13.

The statement that specifies to the compiler about the return type, name of the function and parameters it takes is called as (a)  

14.

The functions defined in the compiler are called as _______

a)

nested function

b)

main function

c)

built-in function

d)

user defined function

15.

Variables whose scope is limited to the function are :

a)

static variables

b)

local variables

c)

global variables

d)

constant variables

16.

what type of function is this ?

void main()

{

int a=10;

cal( a);

}

void cal(int x)

{ x=x*10;

cout<<x;

}

a)

Function with arguments and return value

b)

Function with arguments and no return value

c)

Function with no arguments and return value

d)

Recursive function

17.

Fill in the blank with appropriate statements in the program to calculate largest of two numbers. ( function to be called and filled with statements for calculation)

void main()

{

int m,n;

cin>>n;

_________

}

void larg(int x, int y)

{

_________

cout<<" .........is largest";

--------

cout<<" .........is largest";

}

(a)  

18.

Advantage of functions

a)

reduces complexity of program

b)

global use

c)

avoids unnecessary memory allocation

d)

All of above

19.

The datatype and order of actual parameters may not be same as that of formal parameters. Specify True or False?

a)

True

b)

False

20.

what is the output of the program?

int test(int);

void main()

{

int x=1, z;

z=test(x);

cout<<z;

x++;

z=test(x);

cout<<z;

}

int test(int y)

{

return(y*5);

}

a)

5 10

b)

5 6

c)

5 5

d)

5 2