576 views

3 Answers

Best answer
3 votes
3 votes
intially a=1 then due to inside while loop use post decrement operator which means firstly assign the value then decrement so firstly

while(1==1)true the decrement 'a' by 1 then a become 0 then while(0=0) true then  'a' decrement by 1 by which  a=-1 then go inner while loop  while(-1=0) false then decrement then  a=-2 then go outer while loop again condition false and finally  'a' become -3

so answer is  a=-3
selected by
0 votes
0 votes
Here -- is a post decrement operator

So, in while loop (a>=1) which is true , then a-- gives 0

go to second while loop until get a semicolon

second while loop gets a value as 0

then (a>=0) which is true

then a--

So, after second while loop value of a becomes -1

But for semicolon it cannot go outside of second while loop.

Go to first while loop again (a>=1)  condition false and a becomes -2

Go to second while loop ,again condition false and a becomes -3

Now go outside of while loop and print -3

Related questions

0 votes
0 votes
1 answer
1
TusharKumar asked Dec 22, 2022
532 views
can anyone explain how the for loop works here..?
0 votes
0 votes
2 answers
2
rohitkaushal1 asked Sep 22, 2022
502 views
What will be the output printed for find(4)? void find(int x) { static int i = 10, y = 0; y = y + i; for(i; i>0; i = i - 10) { if(x! = 0) find(x – 1); else printf(“%d...