fun(int x)
{
if(x > 0)
fun(x/2);
printf("%d", x);
}
above function is called as:
fun(10);
what will it print?
}
Answers were Sorted based on User's Feedback
Answer / shilpa m
Right answer is 0.
fun(int x)
{
if(x > 0)
fun(x/2);
printf("%d\n", x);
}
Here if fun(10)is called the sequence goes as fun(10)->fun
(5)->fun(2.5)->fun(1.25)->fun(0.625) after this itself
printf will be executed and 0 is printed.
please expalin how answer is 0 1 2 5 10 is right answer???
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / enigma
Strictly speaking the answer is undefined until someone forces the output text from the console buffer to the screen.
Otherwise it would normally print 012510
Debug it inside MSVC and witness no output. In reality though most implementations will do a final flush to screen....
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / mortal
it will print "0" i.e zero since compiler wont get to the
print statement until the value is zero.
Is This Answer Correct ? | 2 Yes | 5 No |
How is a structure member accessed?
12344321 123 321 12 21 1 1 how i print this program??
5 Answers DSR Management, Winit,
What tq means in chat?
Why the use of alloca() is discouraged?
What is variable and explain rules to declare variable in c?
What is the difference between #include <header file> and #include “header file”?
Difference between macros and inline functions? Can a function be forced as inline?
0 Answers HAL, Honeywell, Zomato,
how to create c progarm without void main()?
write a program to print sum of each row of a 2D array.
What is the difference between fread and fwrite function?
What is the size of a union variable?
what is diff between localstatic and globalstatis variable possible 2 use in another file...?