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 / ashwin kumar

hi Gg

answer is 0 1 2 5 10

this not stack prlm dear

here printf is after the function call dear so it is
printing 0 1 2 5 10

if u wnt to see 10 5 2 1 0 as output plz keep printf
function before function call that is

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

}

but output will be 10 5 2 1 only on 0 is printed

this above new code will give segmentation error in netbeans

thank u dear

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is it possible to have a function as a parameter in another function?

599


What is 2 d array in c?

558


Why can't I perform arithmetic on a void* pointer?

639


What does int main () mean?

551


Why is c faster?

593






A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none

733


what is the syallabus of computer science students in group- 1?

1842


What does void main return?

606


With the help of using classes, write a program to add two numbers.

619


Where are the auto variables stored?

626


How can variables be characterized?

1652


Write a program to show the change in position of a cursor using c

583


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

689


How do you define structure?

567


What are the types of type qualifiers in c?

650