0
Why is my a[0] taking two elements in array
Its a program to add all even numbers in an array https://code.sololearn.com/ckN3o6oHAHLo/?ref=app
2 Respostas
+ 2
#include<stdio.h>
int main()
{
int a[100],n,i,sum=0;
printf("enter how many numbers you want to enter:\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
printf("a[%d]=%d\n",i,a[i]);
}
for(i=0;i<n;i++)
{
if((a[i])%2==0)
sum=sum+(a[i]);
}
printf("sum of even numbers=%d",sum);
}
Give input as-
4
2
5
8
7
Where 4 is the number of elements.
0
Thannks