0
Can anyone tell me how to complete this code when I run this code Test case 1,4,5 fails
#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; }
5 ответов
+ 5
Ipang I suppose he is talking about the "That's odd..." challenge where one have to find the sum of all even integers present in a list of given length N. Let me know if you want all code coach tasks.
Vígñësh M@râdīyå Please remember to provide the challenge name or link next time if you want to get fast an accurate help.
You have a tiny mistake:
sum += *(arr+1); should be:
sum += *(arr + i );
You already solved the task in other languages so it's probably a typo.
+ 3
Kevin ★ Thanks bro for help
+ 3
Ipang 😅
Vígñësh M@râdīyå You're welcome.
+ 2
What was the task requirement? is this one of the code coaches?
I can't view code coaches BTW, so I need to know the task ...
+ 1
Kevin ★
Thanks for telling 🙏
I suppose he might have gotten it figured out through your notes by now 😁👍