Given an array of length N, you need to find and print the sum of all elements of the array. Input Format : Line 1 : An Integer N i.e. size of array Line 2 : N integers which are elements of the array, separated by spaces Output Format : Sum

Given an array of length N, you need to find and print the sum of all elements of the array.

Input Format :

Line 1 : An Integer N i.e. size of array

Line 2 : N integers which are elements of the array, separated by spaces

Output Format :

Sum

Constraints :

1 <= N <= 10^6

Sample Input :

3

9 8 9

Sample Output :

26


Source Code : 

#include<iostream>

using namespace std;

int main(){

    int i,n,sum=0,value,arr[10];

    cin>>n;

    for(i=0;i<n;i++){

        cin>>value;

            sum+=value;

    }

    cout<<sum;

}

Coding NInjas Solutions
Given an array of length N, you need to find and print the sum of all elements of the array. 


Post a Comment

0 Comments