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 |
write a function that accepts an integer/char array and an search item.If the search item is there in the array return position of array and value else return -1.without using other array,without sorting,not to use more than one loop?
a=0; b=(a=0)?2:3; a) What will be the value of b? why b) If in 1st stmt a=0 is replaced by -1, b=? c) If in second stmt a=0 is replaced by -1, b=?
Design a program using an array that lists even numbers and odd numbers separately from the 12 numbers supplied by a user.
i want to know aptitude questions,technical questions
There are N egg baskets and the number of eggs in each basket is a known quantity. Two players take turns to remove these eggs from the baskets. On each turn, a player must remove at least one egg, and may remove any number of eggs provided they all belong to the same basket. The player picking the last egg(s) wins the game. If you are allowed to decide who is going to start first, what mathematical function would you use to decide so that you end up on the winning side? Upload a C program to demonstrate the behaviour of the game.
int main(){ float f=8.0; if(f==8.0) printf("good"); else printf("bad"); } what is the answere and explain it?
program to print upper & lower triangle of a matrix
Differentiate between calloc and malloc.
main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
What is context in c?
Explain why can’t constant values be used to define an array’s initial size?
What is abstract data structure in c?