Output of the Given Source Code
Write the output of the following code: int x,y=0; for(x=1; x<=5; ++x) y=X++; --y;
Answers
Answered by
0
int x, y = 0
for (x = 1 ; x <= 5 ; ++ x)
y = x ++ ;
-- y
===== output =====
=====
x y
=====
1 1
2 1
3 1
3 3
4 3
5 3
5 5
6 5
7 5
7 4
====
so final values of x and y are : 7 and 4. respectively.
for (x = 1 ; x <= 5 ; ++ x)
y = x ++ ;
-- y
===== output =====
=====
x y
=====
1 1
2 1
3 1
3 3
4 3
5 3
5 5
6 5
7 5
7 4
====
so final values of x and y are : 7 and 4. respectively.
Similar questions