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 :

Click on Discuss to view users comments.

Write your comments here:



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 :

Click on Discuss to view users comments.

Write your comments here:



28:  

 Which of the following is/are syntactically correct?

A.

for ( ) ;

B.

f or (;) ;

C.

for ( , );

D.

for ( ; ; ) ;

 
 

Option: D

Explanation :

Click on Discuss to view users comments.

Alok Gupta said: (7:00pm on Friday 26th April 2013)
I feel in 'D' option the semi-colon should not be there at the end of parenthesis. It should be like, for (;;) as, if 'D' option is correct then what is wrong with the 'A' and 'C' option.

Write your comments here:



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 :

Click on Discuss to view users comments.

Write your comments here:



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 :

Click on Discuss to view users comments.

Write your comments here: