When i try this code into playground shows below error | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

When i try this code into playground shows below error

..\Playground\:7: error: cannot find symbol sum += myArray[x]; ^ symbol: variable myArray location: class Program 1 error

27th Feb 2017, 7:37 AM
Niket “Nik” Patil
Niket “Nik” Patil - avatar
8 Answers
+ 3
Let worked Fill in the blanks to make a constant named total and the variable i that is only accessible inside the loop. const total = 100; let sum = 0; for(let i = 0; i < total; i++) { sum += i; }
8th Dec 2019, 2:03 PM
Arjun Singhal
Arjun Singhal - avatar
+ 2
what IS the full code ?
27th Feb 2017, 8:14 AM
Hickacou
Hickacou - avatar
+ 1
public class Program { public static void main(String[] args) { double sum = 0.0; for(int x = 0; x < 4; x++) { sum += myArray[x]; } System.out.println(sum); } }
27th Feb 2017, 9:26 AM
Niket “Nik” Patil
Niket “Nik” Patil - avatar
+ 1
But in questions of Summing Elements in Arrays session is like. Fill in the blanks to calculate the sum of myArray's elements using the for loop, and print it to the screen. myArray is an array of doubles, containing 4 elements. double sum = 0.0; for (int x = 0; x < 4; x__) { sum += myArray[x]; } System.out.println(__); and i enter into fill blanks like below double sum = 0.0; for (int x = 0; x < 4; x++) { sum += myArray[x]; } System.out.println(sum); and this is ans is correct so how it has possible when i run this code into playground is say error. This is work when i pass some values into myArr i know but y says in quetions is correct.
27th Feb 2017, 10:07 AM
Niket “Nik” Patil
Niket “Nik” Patil - avatar
+ 1
const total = 100; let sum = 0; for(let i = 0; i < total; i++) { sum += i; }
29th Apr 2020, 4:40 PM
Druide LEKOGHO
Druide LEKOGHO - avatar
0
SoloLearn, Please respond.
8th Dec 2019, 2:00 PM
Arjun Singhal
Arjun Singhal - avatar
0
Fill in the blanks to make a constant named total and the variable i that is only accessible inside the loop. total = 100; let sum = 0; for( i = 0; i < total; i++) { sum += i; } Any one know this ?
11th Dec 2020, 10:42 AM
Eric Bartolome
Eric Bartolome  - avatar
- 1
Fill in the blanks to make a constant named total and the variable i that is only accessible inside the loop. const total = 100; let sum = 0; for(int i = 0; i < total; i++) { sum += i; } why is this not working?
8th Dec 2019, 2:01 PM
Arjun Singhal
Arjun Singhal - avatar