Computer Science, asked by ltikoo, 5 months ago

What will be the output of the following program:
n=10
s=0
while n <= 50:
s = s + n
n = n + 10
print(s)

Answers

Answered by shahana26
0

Answer :

10 30 60 100 150

Explanation :

initially, n = 10 => sum = 10

n = n + 10 = 10 + 10 = 20 => sum = sum + n = 30

n = 20 + 10 = 30 => sum = 30 + 30 = 60

n = 40 => sum = 100

n = 50 => sum = 150

now n = 60, which is greater than 50. So the control will exit from the loop.

Similar questions