+ 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
8 Antworten
+ 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;
}
+ 2
what IS the full code ?
+ 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);
}
}
+ 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.
+ 1
const total = 100;
let sum = 0;
for(let
i = 0; i < total; i++) {
sum += i;
}
0
SoloLearn, Please respond.
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 ?
- 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?