fun(int x)
{
if(x > 0)
fun(x/2);
printf("%d", x);
}

above function is called as:
fun(10);

what will it print?



}

Answer Posted / mahesh patil

Only answer 1
answer 4
answer 7 are correct others are wrong..
If you are confident on your answers please check once then
write a post.

Correct Answer: 0 1 2 5 10

This will print in reverse order because, This is a
recursive call, Every time a function is called the values
are stored in stack/stack is created. when x value reaches
0 then it will return. So stack is LIFO order, So it will
print the values in reverse order.

Is This Answer Correct ?    9 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Discuss the function of conditional operator, size of operator and comma operator with examples.

680


Can we change the value of static variable in c?

564


Explain what would happen to x in this expression: x += 15; (assuming the value of x is 5)

815


What are variables and it what way is it different from constants?

786


what will be the output for the following main() { printf("hi" "hello"); }

9332






What is .obj file in c?

648


typedef struct{ char *; nodeptr next; } * nodeptr ; What does nodeptr stand for?

1076


How do you write a program which produces its own source code as output?

608


Explain how can you be sure that a program follows the ansi c standard?

865


to find the closest pair

1823


how to execute a program using if else condition and the output should enter number and the number is odd only...

1657


Do you know pointer in c?

593


Is c call by value?

607


Can you please explain the scope of static variables?

602


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

643