Computer Science, asked by ydkumbharkar5556, 9 months ago

What is output?
c = 1
sum = 0
while (c < 10):
c = c + 3
sum = sum + c
print (sum)

Answers

Answered by johnmick
3

Answer:

11

Explanation:

the third iteration c = c + 3 will make it 10 and 10 < 10 is false so answers is 11

Answered by surajnegi0600
0

Answer:

This code defines a variable c with the value of 1, and a variable sum with the value of 0. Then it starts a while loop that will continue to execute as long as the value of c is less than 10.

Explanation:

The while loop starts by incrementing the value of c by 3, so the first time through the loop c is 4. The code then adds the value of c to the value of sum. The first time through the loop sum will be 4, the second time through the loop sum will be 7, and so on.

The while loop continues to execute, incrementing c by 3 and adding that value to sum at each iteration, until the value of c is greater than or equal to 10.

At this point, the loop will exit and the final value of sum will be printed, which is 7+10 = 17.

It's important to note that this specific code has an issue, because the variable c is not being incremented inside the while loop, so the while loop will run indefinitely.

More question and answers:

https://brainly.in/question/12321084

https://brainly.in/question/20945442

#SPJ3

Similar questions