Font size
WorksheetsFunctions in C++
Total questions: 20
Worksheet time: 8mins
The functions are also called as
(a)
what is a function?
Function is a block of statements that perform some specific task.
Function is the fundamental modular unit. A function is usually designed to perform a specific task.
Function is a block of code that performs a specific task. It has a name and it is reusable.
All of the above
The statement used to invoke a function is called as
(a)
For the function specified as: int cal(int, float);, the return statement will :
return the value
does not return the value
returns multiple values
returns 0
Use of functions
Helps to avoid repeating a set of statements many times.
Enhances the logical clarity of the program.
Helps to avoid repeated programming across programs.
Makes the debugging task easier.
All of the above
What are types of Functions in C++ Language.?
A) Library Functions
B) User Defined Functions
C) Both Library and User Defined
D) None of the above
The (a) type of variable has scope throughout the program
The function is executed when it is
prototyped
declared
defined
called
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;
}
4 0
5 4
4 5
4 4
x= display(x,y);
what type of function is this statement belong to?
with arguments and no return value
without arguments and return value
with arguments and with return value
without arguments and no return value
What is the default return type if it is not specified in function definition?
void
int
double
short int
A function which calls itself is called a ___ function.
Self Function
Auto Function
Recursive Function
Static Function
The statement that specifies to the compiler about the return type, name of the function and parameters it takes is called as (a)
The functions defined in the compiler are called as _______
nested function
main function
built-in function
user defined function
Variables whose scope is limited to the function are :
static variables
local variables
global variables
constant variables
what type of function is this ?
void main()
{
int a=10;
cal( a);
}
void cal(int x)
{ x=x*10;
cout<<x;
}
Function with arguments and return value
Function with arguments and no return value
Function with no arguments and return value
Recursive function
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)
Advantage of functions
reduces complexity of program
global use
avoids unnecessary memory allocation
All of above
The datatype and order of actual parameters may not be same as that of formal parameters. Specify True or False?
True
False
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);
}
5 10
5 6
5 5
5 2
