What does the following function print?func(int i){if(i%2)return 0;eale return 1;}main(){int =3;i=func(i);i=func(i);printf("%d",i);}a.3b.1c.0d.2

C
This question is related to TCS Interview

Showing Answers 1 - 11 of 11 Answers

avula tirupathi rao

  • May 7th, 2005
 

it will print 1 not 0 

  Was this answer useful?  Yes

Sinic

  • Aug 23rd, 2005
 

Due to first call i = 0 then it is a param for next call which returns i = 1 
 
Ans : B

  Was this answer useful?  Yes

karna

  • Jul 3rd, 2006
 

hi,

when i =3, if(i%2) becomes if(1) so it will return 0

then when i=0 if(i%2) becomes if(0) so it will return 1;

so i=1 the answer is b.

  Was this answer useful?  Yes

neelu

  • Nov 29th, 2006
 

hi

if i=3 then if(i%2) i.e.,if(3%2) it returns o;

else

if i=0 then if(i%2) i.e.,if(0%2) it returns 1;

the answer is 1 i.e.,option (B).

  Was this answer useful?  Yes

anon1987

  • Dec 7th, 2009
 

Ans :: C
Because :: func(3)  >>>  return(1)   >> i=1;
               func(1) >>>   return(0) (because i is int  type)  >> i = 0 will be printed.

  Was this answer useful?  Yes

avula chiru

  • Sep 30th, 2010
 

The answer is 1 because where i%2 it gives 1 then if condition is true and it returns 0 to the main, again we call the function then if condition fails and then else part execute so answer is 1.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions