Sum the Input
Medium · Loops · while read · Arithmetic
Problem
Numbers arrive on standard input, one per line.
Print their total.
Examples
Input: 1\n2\n3 Output: 6
Approaches
- while read with an accumulator
Related problems
Start free on Cariara · Coding problems · System design studio