Practice

Array Sum

MEDIUMArrays

Read an integer N (1 ≤ N ≤ 10), then read N integers. Output their sum.

Input: N on the first line, then N integers one per line. Output: The sum of all N integers.

Example:

Input:  3
        10
        20
        30
Output: 60

Sample Test Cases

Test 1: 5 numbers
Inputs: 5, 10, 20, 30, 40, 50
Expected: 150
Test 2: 3 numbers
Inputs: 3, 1, 2, 3
Expected: 6

Premium Question

This question needs a paid plan — upgrade, or join a class from a teacher who has one. You can read the description and sample tests, but grading is locked.

Sign in to get started