GATE CSE
First time here? Checkout the FAQ!
x
+1 vote
129 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 | 129 views
1213121

1 Answer

+3 votes

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

answered by Boss (6.6k 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 Aug 2017
  1. ABKUNDAN

    4670 Points

  2. Bikram

    4556 Points

  3. akash.dinkar12

    3420 Points

  4. rahul sharma 5

    3124 Points

  5. manu00x

    2864 Points

  6. makhdoom ghaya

    2450 Points

  7. just_bhavana

    2136 Points

  8. Tesla!

    2042 Points

  9. stblue

    1930 Points

  10. joshi_nitish

    1686 Points


24,970 questions
32,072 answers
74,567 comments
30,150 users