Practice

Totalling Positive Numbers

2023/May/Jun·Variant 1
MEDIUMLoops

Read numbers until 0 is entered. Total only the positive numbers and count how many there were.

Input: A sequence of integers ending with 0. Output: The total and the count of positive numbers.

Example:

Input:  5
        -2
        10
        0
Output: Total: 15
        Count: 2
Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: Mix positive/negative
Inputs: 5, -2, 10, 0
Expected: Total: 15 Count: 2
Test 2: Only negatives
Inputs: -5, -10, 0
Expected: Total: 0 Count: 0
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade