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
5 odpowiedzi
+ 2
Where is your code?
Share link here...
+ 1
thank you
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?
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.