• edited by
7,642 views

5 Answers

1 1 vote
A.0,0,1,2,3,4 --- 0 printed twice because of --x statement @ if condition for fun(0) 0 is printed and for fun(1) 0is printed because value x is decremented before fun(0) fun call starts to execute!
1 1 vote
Key point which u have to note here is that there is no braces after the if statement therefore the first statement written after it would only fall into the if portion so myfunc(0) when called would simply print 0 ,so 2  0's would be printed. it won't enter into the if check condition and rest explanation is already given by others ,My intention was to just highlight the braces portion.
0 0 votes

A. 0,0,1,2,3,4 

recursive call sequence -myfun(5)--> myfun(4)--> myfun(3)--> myfun(2)--> myfun(1)-->myfun(0)

so,myfun(0) prints a 0 then myfun(1) prints  0 again as 1 in decremented first in  similiar way then 2 ,3 and lastly 4 get printed.

Position:
Show:

Related questions

0 0 votes
1 1 answer
464
464 views
shivamSK asked Jun 9, 2024
464 views
#include <stdio.h double pom(double x,int n){ if(n==1) return x; else return x*pom(x,n-1); n; } int main() { int a=pom(2,5); printf("%d",a); return 0; }what is the outpu...
1 1 vote
1 1 answer
392
392 views
shivamSK asked Jun 9, 2024
392 views
what is output of this c codeA: 321B: 123C: error(infinite/segmentation)D:333
1 1 vote
2 2 answers
1.8k
1.8k views
Umang Raman asked Oct 7, 2015
1,841 views
int main (){ int a=5,b=3; printf("%d", a+++++b); // 5 +'s }Please Explain.
1 1 vote
3 3 answers
2.2k
2.2k views
ajit asked Oct 1, 2015
2,154 views
what is the output of the following c code?#include<stdio.h void main() { int index; for(index=1;index<=5;index++) { printf("%d",index); if(index==3) continue; } }a)1245b...