GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
76 views

Avoid the any syntax error ,if there is:What will be the output of the following code ?
 

#inlcude<stdio.h>
void myfun(int i)
{   
    if(i>0) {
        myfun(i-1);
        printf("%d",i);
        myfun(i-1);
    }
}
int main() {
    myfun(3);
}

asked in Programming by (107 points)  
edited by | 76 views
1213121

1 Answer

+3 votes

execute the tree from DFS manner you will get the output 1213121

answered by Boss (5.5k points)  

Why isn't the right sub tree getting executed first? What I mean is shouldn't the solution be 1211213 ?

PLease explain a bit more. 



Top Users Mar 2017
  1. rude

    4018 Points

  2. sh!va

    2994 Points

  3. Rahul Jain25

    2804 Points

  4. Kapil

    2606 Points

  5. Debashish Deka

    2092 Points

  6. 2018

    1414 Points

  7. Vignesh Sekar

    1318 Points

  8. Bikram

    1218 Points

  9. Akriti sood

    1166 Points

  10. Sanjay Sharma

    1004 Points

Monthly Topper: Rs. 500 gift card

21,439 questions
26,753 answers
60,919 comments
22,929 users