how isn't it working... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how isn't it working...

please help me guys with what happenig here... my coding isnt that good. public class Program { public static void main(String[] args) { int[] n = { 0,1,2,3,4,5,6,7,8,9 }; int sum = 0; int c = 0; for (int i = 1; i <= n.length; i++) { if (i%2 == 0) { sum += i; c++; } } System.out.println(sum); } }

22nd Dec 2020, 4:22 AM
BloggerLife
BloggerLife - avatar
4 Answers
0
its for adding even numbers from a list
22nd Dec 2020, 4:23 AM
BloggerLife
BloggerLife - avatar
0
what do you want to do? 🤔
22nd Dec 2020, 4:24 AM
Shahghasi Adil
Shahghasi Adil - avatar
0
i want to add all the even numbers in that array
22nd Dec 2020, 4:26 AM
BloggerLife
BloggerLife - avatar
0
wow, its working on my ide but sololearn is rejecting the answer, i dont know why...
22nd Dec 2020, 6:12 AM
BloggerLife
BloggerLife - avatar