Classical

C Programming MCQ - Functions & Recursion

26:  

Feature for accessing a variable through its address is desireable because

A.

call by reference can be simulated 

B.

excessive use of global variables can be avoided

C.

a function can return more than one value

D.

All of the above

 
 

Option: D

Explanation :


27:  

It is not advisable to use macros instead of functions because

A.

it increases the code size

B.

no type checking will be done

C.

recursion is not possible 

D.

All of the above

 
 

Option: D

Explanation :


28:  

 Which of the following is/are syntactically correct?

A.

for ( ) ;

B.

f or (;) ;

C.

for ( , );

D.

for ( ; ; ) ;

 
 

Option: D

Explanation :


29:  

Use of macro instead of function is recommended

A.

when one wants to reduce the execution time

B.

when there is a loop with a function call inside

C.

when a function is called in many places in a program

D.

both (a) and (b)

 
 

Option: D

Explanation :


30:   Following is a recursive function for computing the sum of integers from 0 to N.
function sum(N:integer):integer
begin
if N=0 then Sum=0
else
end;
The missing line in the else part is
A. Sum:=N+Sum(N)
B. Sum:=N+Sum(N-1)
C. Sum:=(N-1)+Sum(N+1)
D. Sum:=(N-1)+Sum(N-1)
 
 

Option: B

Explanation :




Suggest an improvement