output : int a=5;
for(int i=6;i>0;i--)
{
a=a+i;
i=i-1;
System.out.print(a+" ");
}
Answers
Answered by
2
ANSWER.
- Output for the question is - 11 15 17
EXPLANATION.
The initial value of a is 5.
When i = 6,
→ a = a + i
→ a = 5 + 6
→ a = 11
→ i = i - 1
→ i = 5
> a is printed and value of 'i' is decremented.
When i = 4,
→ a = a + i
→ a = 11 + 4
→ a = 15
→ i = i - 1
→ i = 3
> a is printed and value of 'i' is decremented.
When i = 2,
→ a = a + i
→ a = 15 + 2
→ a = 17
→ i = i - 1
→ i = 1
> a is printed and value of 'i' is decremented.
Now, the loop terminates.
So, the final output is - 11 15 17
Similar questions
Music,
1 month ago
Math,
1 month ago
Geography,
1 month ago
Biology,
9 months ago
Computer Science,
9 months ago