Computer Science, asked by lakhidasgupta, 5 months ago

what will be the output of the code?

Please answer correctly.
Orelse I will report it.
I will thank all your answers who ever will answer correctly.​

Attachments:

Answers

Answered by subgb98
0

Answer:

output:

Sum = 25

loop will execute 5 times

Explanation:

Answered by anindyaadhikari13
1

Question:-

Write the output of the following code.

Working Out:-

Given code in JavaScript,

var i=1,S=0;

while(i<=10)

{

S=S+i;

i=i+2;

}

After first iteration,

S=1

i=3

After second iteration,

S=1+3=4

i=5

After third iteration,

S=4+5=9

i=7

After fourth iteration,

S=9+7=16

i=9

After fifth iteration,

S=16+9=25

i=11

As i<=10 is false so loop terminates.

Output:-

Sum = 25.

Here we can see that the loop executes 5 times.

Similar questions