Computer Science MCQs Programming C++ Sample 02
TOPIC: FUNCTION
1.The main advantage of
function
·
Reusability
·
Safe memory space
·
Direct use of memory
·
Continuity
·
Error Recovery
2.tick any one valid pre-define
function.
·
sqrt()
·
Power()
·
cin
·
main()
3.Can a function
have a local variable with the same name as a global variable?
·
Yes
·
No
4.When a function accepts multiple arguments, does it matter what order the arguments are passed in?
·
yes
·
No
5.A(n) ___
variable is defined inside a function and is
not accessible
outside the
function .
·
local
·
global
·
static
6.The ____is the part of a function definition that shows the function name, return type, and parameter list.
·
Function header
·
Function body
·
Function definition
·
Function call
7.If a function doesn't return a value,
the word ____ will appear as its
return type.
·
void
·
return 0
·
Void
·
nothing
8.If function showValue has the following header: void showValue( int
quantity) you would use the statement ____
to call it with the argument 10.
·
showValue(10);
·
Void showValue(10);
·
showValue(int 10);
·
void showValue(int 10);
9.Values that are sent into a
function are called
·
Arguments
·
Parameters
·
Return values
·
Parameter list
10.The ____ function causes a program
to terminate immediately.
·
exit
·
return
·
break
·
end
11.The ____ statement causes a function to end immediately.
·
return
·
exit
·
break
·
end
12.Indicate which of the following
is the function prototype:
·
void showNum(double num);
·
void showNum(double num)
·
void showNum(double num);{}
·
showNum(45.67 );
13.How many return values may a function have?
·
1
·
0
·
2
· 3
·
100 100 100
·
100 50 100
·
100 50 50
·
100 100 50
·
Output will be 30, No error found
·
Function should pass two
arguments
·
Function should have only one
parameters
·
Statement terminator missing
after function declaration.
16. Consider the following code.
Determine the error if found
·
Function should return a value
·
Statement terminator missing after function header
·
No error
·
Too many function parameters
·
10 9 8 7 6
·
1 2 3 4 5
·
10 10 10 10 10
·
10 9 10 9 10
·
2.4
·
10.8
·
0
·
2
· 51
· 10.8
· 2.4
· 20.4
You can find solution here solution-of-programming-sample-02
Comments
Post a Comment