A Very Big Sum Hacker Rank Solution In C-language | | Hacker Rank Solutions

A Very Big Sum Hacker Rank Solution In C-language | | Hacker Rank Solutions

Question


Calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large.
Input Format
The first line of the input consists of an integer 
The next line contains  space-separated integers contained in the array.
Output Format
Print the integer sum of the elements in the array.


Answer

#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main() {
      long long int a[10],n,i,sum=0;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(i=0;i<n;i++)
        sum=sum+a[i];
    printf("%lld",sum); 
    return 0;
}

Comments :

Post a Comment