Simple Array Sum

Sort by

recency

|

3454 Discussions

|

  • + 0 comments

    Java 15

    This is my code for Java 15 :-

    public static int simpleArraySum(List<Integer> ar) {
        int sum = 0;
        for(int i: ar) sum+=i;
        return sum;
    }
    
  • + 0 comments

    For Python3 Platform

    with python, you can use the sum function. But with other languages, you have to use the loop to calculate the sum

    def simpleArraySum(ar):
        return sum(ar)
    
    n = int(input())
    ar = list(map(int, input().split()))
    
    result = simpleArraySum(ar)
    
    print(result)
    
  • + 0 comments

    def simpleArraySum(ar): c = 0 for i in ar:
    c = c + i return c

  • + 0 comments

    Elite Aviations' emphasis on speed, security, and tailored logistics aligns well with the needs of industries like is bsd brawl safe, where secure and rapid transportation of sensitive or high-value equipment is critical. Their global reach ensures reliable support for urgent deployments, making them a strategic logistics partner in high-stakes environments.

  • + 0 comments

    include

    int main() { int n,sum=0; int i; scanf("%d",&n); int a[n];

    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    
    for(i=0;i<n;i++)
    sum=sum+a[i];
    

    { printf("%d",sum); }

    }