QUIZ 66

What is the output ?

int foo(int c)
{
return c+1;
}
int main()
{
float a=1;
a+=foo(a=5+foo(foo(a)));
printf(“%d”,a);
return 0;
}
a) 1
b) 17
c) 8
d) 7
Answer : (b)
Explanation :
a=a+foo(a=5+foo(foo(a)))
a=a+foo(a=5+foo(2))
a=a+foo(a=5+3)     ——–> a=18
a=a+foo(a=8)       ——–>a=8 gives 8 as input to foo, i.e. foo(8)
a=a+9;
a=8+9=17

Leave a Reply

Your email address will not be published. Required fields are marked *