output : int a=2;
for(int i=3;i>0;i--)
{
a=a+i;
System.out.print(a+" ");
}
Answers
Answered by
1
ANSWER.
- The output of the question is - 5 7 8
EXPLANATION.
The initial value of a is 2
The given loop iterates 3 times (i = 3, 2, 1)
When i = 3,
→ a = a + i
→ a = 2 + 3
→ a = 5
> a is printed.
When i = 2,
→ a = a + i
→ a = 5 + 2
→ a = 7
> a is printed.
When i = 1,
→ a = a + i
→ a = 7 + 1
→ a = 8
> a is printed.
So, the numbers 5, 7 and 8 are printed with a space in between.
Therefore, the final output is - 5 7 8
Similar questions