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--));
}
Hello @DebSujit please check you Linkdin message section !
@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.
@gatecse Ah correct! Got it sir.
64.3k questions
77.9k answers
244k comments
80.0k users