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
Is it possible to have a function as a parameter in another function?
What is 2 d array in c?
Why can't I perform arithmetic on a void* pointer?
What does int main () mean?
Why is c faster?
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
what is the syallabus of computer science students in group- 1?
What does void main return?
With the help of using classes, write a program to add two numbers.
Where are the auto variables stored?
How can variables be characterized?
Write a program to show the change in position of a cursor using c
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)
How do you define structure?
What are the types of type qualifiers in c?