What is the output of the following program?
int fun (int z) { if( z==0 || z==1 ) return 1; else return fun(z-1) ; } int main() { int y; y=fun(8); printf(“%d”, y) ; }
ans A
every time the fun(z) is just either calling fun(z-1) or returning 1 hence the output doesn’t depend on the value of z it will always return 1 , for every non negative z
64.3k questions
77.9k answers
244k comments
80.0k users