edited by
705 views
0 votes
0 votes

void PrintValue(int n) 
{

   if (n < 0) return;
   else 
   {
     printf(n);
     printValue(--n);
     printValue(n--);
     printf(n);
   }

}



Output for Print(5) ?

edited by

2 Answers

2 votes
2 votes
5+4+3+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+1+3+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+1+2+4+3+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+1+3+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+2+1+0+(-2)+0+(-2)+(-1)+1+0+(-2)+0+(-2)+(-1)+0+1+2+3

 

-12 is the answer
0 votes
0 votes
In printf(n)  ,

where is your format specifier ?

 

please corrects  the code .

Related questions

2 votes
2 votes
0 answers
1
srestha asked Jan 28, 2019
620 views
void foo(int n) { for(i1=1;i1<=n;i1++) { for(i2=1;i2<=i1;i2++) { ....... { for(i6=1;i6<=i5;i6++) { count++; } } } } }Count initially 0.What is value returned by foo(8)?
3 votes
3 votes
2 answers
2
Shamim Ahmed asked Dec 11, 2018
546 views
char *a = “MADEEASY”;char *b = “GATECSIT2019”;char *r = a;char *s = b;printf(“%d”, (int) strlen (b+3[r] – 1[s]));return 0; Whats the output? Answer given 8
2 votes
2 votes
2 answers
3