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
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
Math,
4 months ago
Social Sciences,
4 months ago
English,
9 months ago
Computer Science,
9 months ago
Science,
1 year ago
Math,
1 year ago