top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Given an array of N integers, can you find the sum of its elements? write in c code.

0 votes
1,306 views
Given an array of N integers, can you find the sum of its elements? write in c code.
posted Apr 6, 2016 by Saurabh Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
#include<stdio.h>
main()
{
        int i,len,sum=0;
        printf("Enter length of an array\n");
        scanf("%d",&len);
        int arr[len];
        for(i=0;i<len;i++)
        {
                printf("\nEnter arr[%d]  =  ",i);
                scanf("%d",arr+i);
        }
        for(i=0;i<len;i++)
                sum=sum+arr[i];
        printf("\nSum   =   %d \n\n",sum);
}
answer Apr 7, 2016 by Chirag Gangdev
Similar Questions
0 votes

Given an unordered array A of size n and integer x. What is the best complexity to find two elements in A whose sum is x?
Share the algo, its complexity and if possible C code.

+1 vote

Given a array of integers there is one that is repeated several time. How would you compute the length of the sequence of repeated elements.

...