Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is call..

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

fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is call..

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

fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is call..

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

fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is call..

Answer / vinay

10,5,2,1

after that it terminated.

Is This Answer Correct ?    1 Yes 4 No

fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is call..

Answer / sri

0

Is This Answer Correct ?    1 Yes 6 No

fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is call..

Answer / divya

0

Is This Answer Correct ?    1 Yes 9 No

fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is call..

Answer / megha

5

Is This Answer Correct ?    1 Yes 15 No

Post New Answer

More C Interview Questions

how to print the character with maximum occurence and print that number of occurence too in a string given ?

0 Answers   Microsoft,


How can you find the day of the week given the date?

0 Answers  


Can you please explain the difference between exit() and _exit() function?

0 Answers  


int x=sizeof(!5.856); What will value of variable x?

2 Answers  


Whats s or c mean?

0 Answers  


Write a program that can show the multiplication table.

0 Answers   Student,


Explain what is the difference between the expression '++a' and 'a++'?

0 Answers  


Write a C program to check a number even or odd, without using any relational, arithmetic operator and any loops.

1 Answers  


marge linklist

0 Answers   HCL,


c program to input values in a table(using 2D array) and print odd numbers from them

1 Answers  


for(i=0;i=printf("Hello");i++); printf("Hello"); how many times how will be printed?????????

8 Answers  


main() { int i = 1; int num[] = {1,2,3,4}; num[i] = i++; printf("%d", num[i]); } what will be the output? }

22 Answers   NDS, TCS,


Categories