ALLInterview.com :: Home Page Forum9.Com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage   interview questions urls   External Links  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories >> Software >> Programming-Languages >> C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
Question
fun(int x)
{
 if(x > 0)
   fun(x/2);
 printf("%d", x);
}

above function is called as:
 fun(10);

what will it print?



}
 Question Submitted By :: Sid08
I also faced this Question!!     Rank Answer Posted By  
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 1
0 1 2 5 10
 
0
Guest
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 2
5
 
0
Megha
 
 
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 3
0
 
0
Divya
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 4
0 1 2 5 10...Please don't post the wrong answer.
 
0
Raj
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 5
it will print "0" i.e zero since compiler wont get to the
print statement until the value is zero.
 
0
Mortal
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 6
Guest & Raj is correct.......
Please don't post the wrong answer if u r not  clear about this
 
0
Code
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 7
0 1 2 5 10 is the answer. But can anybody explain why the
printing order 0 1 2 5 10. Why not 10 5 2 1 0 ? please...

Is it depends on stack allocation??
 
0
Gg
 
  Re: fun(int x) { if(x > 0) fun(x/2); printf("%d", x); } above function is called as: fun(10); what will it print? }
Answer
# 8
10,5,2,1

after that it terminated.
 
0
Vinay
 
 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
We can draw a box in cprogram by using only one printf();& without using graphic.h header file? NIIT1
What is the difference between char a[] = "string"; and char *p = "string"; ? Honeywell7
1,4,8,13,21,30,36,45,54,63,73,?,?. Franklin-Templeton3
the format specified for hexa decimal is a.%d b.%o c.%x d.%u TCS3
main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); } what is the output? Ramco3
main() { int x=10,y=15; x=x++; y=++y; printf("%d %d\n",x,y); } output?? Ramco11
How do I declare a pointer to an array?  4
O,T,T,F,F,S,S,E,N,?,?,?,T,F,F,S,S,E,N ADP5
why you will give me a job in TCS. TCS5
How do you write a program which produces its own source code as its output?  2
What is macro? IBM3
Which of these statements are false w.r.t File Functions? i)fputs() ii)fdopen() iii)fgetpos() iv)ferror() A)ii B)i,ii C)iii D)iv Accenture3
Give the output for the following program. #define STYLE1 char main() { typedef char STYLE2; STYLE1 x; STYLE2 y; clrscr(); x=255; y=255; printf("%d %d\n",x,y); } ADITI1
what will be the result of the following program ? char *gxxx() { static char xxx[1024]; return xxx; } main() { char *g="string"; strcpy(gxxx(),g); g = gxxx(); strcpy(g,"oldstring"); printf("The string is : %s",gxxx()); } a) The string is : string b) The string is :Oldstring c) Run time error/Core dump d) Syntax error during compilation e) None of these IBM2
if ENTERED FIVE DIGITS DESIGN A PROGRAM THAT WILL FIND CORRESPONDING VALUE FROM ASCII TABLE  1
If we have an array of Interger values, find out a sub array which has a maximum value of the array and start and end positions of the array..The sub array must be contiguious. Take the start add to be 4000. For Ex if we have an array arr[] = {-1,-2,-5,9,4,3,-6,8,7,6,5,-3} here the sub array of max would be {8,7,6,5} coz the sum of max contiguous array is 8+7+6+5 = 26.The start and end position is 4014(8) and 4020(5). Microsoft3
C passes By value or By reference? Geometric-Software3
Explain in detail how strset (string handling function works )pls explain it with an example.  1
How many ways are there to swap two numbers without using temporary variable? Give the each logic.  4
what is the use of using linked list and array? Infosys7
 
For more C Interview Questions Click Here 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com