output : int a=5;
for(int i=0;i<3;i++)
{
a=a-i;
System.out.print(a);
}
Answers
Answered by
1
ANSWER.
- Output for the question is - 542
EXPLANATION.
The initial value of a is - 5
The given loop iterates 3 times. (i = 0, 1, 2)
When i = 0,
→ a = a - i
→ a = 5 - 0
→ a = 5
> a is printed.
When i = 1,
→ a = a - i
→ a = 5 - 1
→ a = 4
> a is printed.
When i = 2,
→ a = a - i
→ a = 4 - 2
→ a = 2
> a is printed.
Now, the loop terminates as the condition given becomes false.
So, the final output is - 542
Similar questions