C
Programming and Technical
Programming
Program
what is printed when the following program is compiled and executed?
int
func (int x)
{
if (x<=0)
return(1);
return func(x -1) +x;
}
main()
{
printf("%dn",func(5));
}
Read Solution (Total 5)
-
- 5+4+3+2+1+1=16
- 10 years agoHelpfull: Yes(1) No(0)
- 16 because there is 6 func push in stack
- 10 years agoHelpfull: Yes(0) No(0)
- it's a recursive call.. at last it return 16.
- 10 years agoHelpfull: Yes(0) No(0)
- 5+4+3+2+1+1 = 16
- 10 years agoHelpfull: Yes(0) No(0)
- ans: 16
checking the condition x - 10 years agoHelpfull: Yes(0) No(0)
C Other Question