Computer Science, asked by vidhisahni16986, 6 months ago

The output for following code is-
int s=0;
for (int i=1;i<=10; i++)
{
S=S+i;
}
System.out.println(s);​

Answers

Answered by anindyaadhikari13
4

Question:-

  • Find the output of the following code.

Working Out:-

Given code,

int s=0;

for (int i=1;i<=10; i++)

{

s=s+i;

}

System.out.println(s);

At first, s=0

After each iteration,

s=0+1+2+3+....10=55.

Now, s gets printed.

So,

Output:- 55

Output:-

55.

Similar questions