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
How can I convert a number to a string?
Tell me when would you use a pointer to a function?
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
Differentiate fundamental data types and derived data types in C.
What are operators in c?
any restrictions have on the number of 'return' statements that may be present in a function. a) no restriction b) only 2 return statements c) only 1 return statements d) none of the above
How will you delete a node in DLL?
any limit on the number of functions that might be present in a C program a) max 35 functions b) max 50 functions c) no limit d) none of the above
What functions are used in dynamic memory allocation in c?
Can you please compare array with pointer?
What is the difference between scanf and fscanf?
Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)
What is calloc() function?
Which node is more powerful and can handle local information processing or graphics processing?
how to print the character with maximum occurence and print that number of occurence too in a string given ?