edited by
6,539 views

5 Answers

1 votes
1 votes
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 votes
1 votes
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 votes
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.

Related questions

1 votes
1 votes
2 answers
1
Umang Raman asked Oct 7, 2015
1,160 views
int main (){ int a=5,b=3; printf("%d", a+++++b); // 5 +'s }Please Explain.
1 votes
1 votes
3 answers
2
ajit asked Oct 1, 2015
1,613 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...
0 votes
0 votes
1 answer
3
Rohit Gupta 8 asked Nov 8, 2017
7,114 views
Let A be a square matrix of size n x n. Consider the following program. What is the expected output?C = 100 for(i=0; i<n; i++) for (j=0; j<n; j++) { Temp = A[i][j] + C A[...
2 votes
2 votes
2 answers
4
gaurav9822 asked Aug 29, 2016
737 views
#include <stdio.h int gsum(int *a,int n) { if(n<=0) return 0; else { if(*a%2==0) return *a+gsum(a+1,n-1); else return *a-gsum(a+1,n-1); } } int main(void) { // your code ...