Computer Science, asked by shivangi726, 2 days ago

output : int a=5;

for(int i=6;i>0;i--)

{

a=a+i;

i=i-1;

System.out.print(a+" ");

}​

Answers

Answered by anindyaadhikari13
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