0

pls help

Summing Elements in Arrays You are given a program that takes the length of the array as the first input, creates it, and then takes the next inputs as elements of the array. Complete the program to go through the array and calculate the sum of the numbers that are multiples of 4. Sample Input 5 4 9 16 2 7 Sample Output 20 MY CODE not correct!!! https://code.sololearn.com/cA8A14A9A1A2/#java

2nd Mar 2021, 1:17 PM
lordzrealm
lordzrealm - avatar
5 Respostas
+ 2
Where is your code? Share link here...
2nd Mar 2021, 1:24 PM
Jayakrishna 🇮🇳
+ 1
thank you
2nd Mar 2021, 1:58 PM
lordzrealm
lordzrealm - avatar
0
Hello. Can you copy-paste your code or (save it in Playground and give the link), so that we might understand what is wrong with your code?
2nd Mar 2021, 1:24 PM
#0009e7 [get]
#0009e7 [get] - avatar
2nd Mar 2021, 1:30 PM
lordzrealm
lordzrealm - avatar
0
1) You need to declare the "sum" variable outside the "for" loop, otherwise it will be initialized and its value will be set to 0 each iteration and it will not be accessible outside this loop. 2) Use the "+=" operator.
2nd Mar 2021, 1:35 PM
#0009e7 [get]
#0009e7 [get] - avatar