+ 1

[Solved] That’s odd... problem (Code Coach)

Could you please take a look at my code, i believe it should work but the SoloLearn app says it otherwise. #include <stdio.h> #include <stdlib.h> int main() { int len, i; int sum = 0; int *arr; scanf("%d", &len); arr = (int*) malloc(len * sizeof(int)); for(i=0; i < len; i++) { scanf("%d", arr+i); if(*(arr+i)%2 == 0){ sum += *(arr+1); } } printf("%d", sum); free(arr); return 0; } Thank you!

4th Mar 2020, 2:53 PM
Zseta
2 RĂ©ponses
+ 3
It should be sum += *(arr+i);
4th Mar 2020, 3:08 PM
Diego
Diego - avatar
+ 1
Ok, it seems i am blind. Thank you very much! :)
4th Mar 2020, 3:37 PM
Zseta