131k views
2 votes
What is the output? (The following language is in python)

c = 1
sum = 0
while (c < 10):
c = c + 2
sum = sum + c
print (sum)

User Sampgun
by
6.8k points

1 Answer

3 votes

Answer:

3

8

15

24

35

Step-by-step explanation:

Loop continues until c is >= 10

Before the print statements the following values are present

1st print: c = 3, sum = 3

next, c = 5, sum = 8

c = 7, sum = 15

c = 9, sum = 24

c = 11, sum = 35

Now at the top of the loop c is greater that 10 so the program ends.

User PRao
by
7.6k points