Contents

What is the output of following function?
int qqq(int k) { if(k<1) return k;}
else return qqq(k-3)+qqq(k/2);}
a) -7       
b) -6                       
c) -5                       
d) -2

a

What value would the following function return when called with argument?
int factorial (int n) {
int product=0; while (n>0) {product = product*n;
n--;} return product;}
a) 0                        
b) 6                        
c) 10                      
d) 12

a

What is the value of b after following function call?
a) int b=3; mystery(b);
void mystery (int & val) {
for (int c=0; c<5; c++)
val=val+2;
}
a) 13      
b) 16                      
c) 12                      
d) 11

a

Which of the following function / types of function cannot have default parameters?
a) member function of class            
b) main ()
c) member function of structure      
d) both b & c

d

Which of the following is correct way to declare pure virtual function?
a) virtual void foo () =0;                                  
b) void virtual foo={0}
c) virtual void foo () {} =0;                               
d) none of these

a

What is the scope of variable declared in user defined function?
a) whole program
b) only inside block {}
c) main function  
d) none of these

b