There is a problem I'm facing where I need to take some array as input and then give their sum as output. But unfortunately I'm getting the worng output here. Can anyone explain what's wrong with this code?
#include<stdio.h>
int main()
#define N size
{
int size,i,sum=0;;
scanf("%d",&size);
int a[N];
for(i=0; i<size; i++)
{
scanf("%d", &a[i]);
}
for(i =0; i<size; i++)
{
sum = a[i] + sum;
}
printf("%d",sum);
return 0;
}
Result:
Input (stdin)
5
1000000001 1000000002 1000000003 1000000004 1000000005
Your Output (stdout)
705032719
Expected Output
5000000015