0 0 votes What will be the return value of the below function, if it is called a sample(4)? int sample(int x){ if( x == 0 || x ==2) return 1; return (sample(--x) * (x--)); } Programming in C programming-in-c recursion bad-question + – abhinowKatore 1.2k views answer comment Share Follow Print See all 7 Comments 7 7 Comments reply DebRC commented Dec 5, 2022 i edited by DebRC Dec 6, 2022 reply Follow flag $sample(4) = sample(3)*3 = (sample(2)*2)*3 = (1*2)*3 = 6$ Edit: Wrong answer. Question is compiler dependent. So, the output can be more than one depending on how the compilers execute the Line 3. 1 1 replyShare Pranavpurkar commented Dec 5, 2022 reply Follow flag Yes , 6. 0 0 replyShare gatecse commented Dec 5, 2022 reply Follow flag int x = 5; int y = --x * x++; What’s the value of y? 0 0 replyShare DebRC commented Dec 5, 2022 i edited by DebRC Dec 6, 2022 reply Follow flag @gatecse A compiler dependent result just like the above question. 0 0 replyShare abhinowKatore commented Dec 5, 2022 reply Follow flag Hello @DebSujit please check you Linkdin message section ! 1 1 replyShare gatecse commented Dec 5, 2022 reply Follow flag @DebSujit it is compiler dependent but not compiler defined. So you cannot guarantee that gcc will always give the same result. Such codes are not meant to be written by half a decent programmer and similarly won't be asked in any good exams except may be to check undefined behaviour knowledge. 3 3 replyShare DebRC commented Dec 6, 2022 reply Follow flag @gatecse Ah correct! Got it sir. 1 1 replyShare Please log in or register to add a comment.