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

What is the right type to use for boolean values in c? Is there a standard type?

549


How can I find the modification date and time of a file?

592


What is the main difference between calloc () and malloc ()?

562


What is a program flowchart?

590


What does void main return?

595






When we use void main and int main?

577


a formula,a series of steps,or well defined set of rules for solving a problem a) algorithem b) program c) erdiagram d) compiler

603


What is volatile variable in c?

649


What is New modifiers?

655


Using which language Test cases are added in .ptu file of RTRT unit testing???

3567


What is the use of function in c?

700


What is the total generic pointer type?

714


Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record

4733


What is the advantage of a random access file?

631


Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.

1583