in Programming in C edited by
211 views
0 votes
0 votes

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) ;
}
  1. $1$
  2. $36$
  3. $8$
  4. $40$
in Programming in C edited by
by
211 views

1 Answer

0 votes
0 votes

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 

Answer:

Related questions