149k views
5 votes
Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the count of how many numbers were entered.

Sample Run
Enter a number: 1
Enter a number: 41
Enter a number: 36
Enter a number: 25

Sum: 103
Numbers Entered: 4
Hint: If you get an EOF error while running the code you've written, this error likely means you're asking for too many inputs from the user.

User Schu
by
5.4k points

1 Answer

7 votes
In python:
total = 0
i = 0
while total <= 100:
number = int(input("Enter a number: "))
i += 1
total += number
print("Sum: {}".format(total))
print("Numbers Entered: {}".format(i))
User Karthikeyan Gopall
by
5.0k points