B. Summation
Problem Setup
- login to CS50 IDE
- write
cdin the terminal to go to the home directory - write
mkdir summation-2to create a folder calledsummation-2 - write
cd summation-2to go to thesummation-2folder - write
code summation-2.cppto create a file calledsummation-2.cppand open it in the editor
Problem
Given an array of \(n\) elements, implement a function that finds the summation of the array.
Input
The first line of input contains an integer \(n\) where \(1 \leq n \leq 1000\), denoting the number of elements in the array.
The second line contains \(n\) integers separated by space, where \(1 \leq a_i \leq 1000\) — representing the elements of the array.
Output
Output the summation of the array.
Examples
Example 1:
Input:
5
1 5 3 2 4
Output:
15
Example 2:
Input:
7
1 4 3 4 3 2 5
Output:
22
Test Your Code
Make sure you are in the summation-2 directory, then run the following command:
check50 iti-technical-team/week3/2026/3/summation-2
Submit Your Code
Make sure you are in the summation-2 directory, then run the following command:
submit50 iti-technical-team/week3/2026/3/summation-2