Embercode
✕
Pointers and Memory AddressesCoding problems

Pointers and Memory Addresses: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 7 solved

  • A warehouse logs the daily change in stock for each of its bins. The manager wants the net change across all bins, so you walk the array with a pointer from the first value to one past the last, and add each value into a total.

    The total can be larger than an int can hold, so use a long long for the running sum.

    **Constraints:** n is at least 1 and at most 100000. Each value is between -1000000000 and 1000000000.

    Input. The first line holds n. The second line holds n integers separated by spaces.

    Output. One integer: the sum of all the values.

    Example 1 input

    3
    1 2 3
    

    Output

    6
    

    Example 2 input

    4
    -5 10 -20 15
    

    Output

    0