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

1 Answer

+3 votes

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

answered by Boss (5.7k 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 Jun 2017
  1. Bikram

    3704 Points

  2. Hemant Parihar

    1502 Points

  3. junaid ahmad

    1432 Points

  4. Arnab Bhadra

    1416 Points

  5. Niraj Singh 2

    1391 Points

  6. Debashish Deka

    1246 Points

  7. Rupendra Choudhary

    1194 Points

  8. rahul sharma 5

    1158 Points

  9. Arjun

    956 Points

  10. srestha

    950 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 Jun 19 - 25
  1. Bikram

    1960 Points

  2. Niraj Singh 2

    1386 Points

  3. junaid ahmad

    502 Points

  4. Debashish Deka

    414 Points

  5. sudsho

    410 Points


23,373 questions
30,079 answers
67,406 comments
28,396 users