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

10th Sep 2020, 6:34 AM
Prashant Pandey
Prashant Pandey - avatar
2 odpowiedzi
+ 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.
10th Sep 2020, 7:02 AM
Avinesh
Avinesh - avatar
0
Thannks
10th Sep 2020, 7:21 AM
Prashant Pandey
Prashant Pandey - avatar