91.4k views
1 vote
What is output by the following code?

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

User Majman
by
4.8k points

1 Answer

4 votes

Answer:

if the code is like this, theres an indent on the print(sum)

c = 1

sum = 0

while (c < 10):

c = c + 2

sum = sum + c

print (sum)

the output would be:

3

8

15

24

35

or

if the code look like this, it has no indent on print(sum)

c = 1

sum = 0

while (c < 10):

c = c + 2

sum = sum + c

print (sum)

the output would be:

35

User GriFlo
by
5.3k points