Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

Level8>Lesson5 second 'for' loop to print the array elements[error]

package main
import "fmt"

func main() {
var listOfTwenty [20] int
for i := 0; i < 20; i++ {
listOfTwenty[i] = i+1
}
fmt.Println("Here is the list of 20 numbers:")
for j := 0; j<len(listOfTwenty);j++ {
fmt.Println(listOfTwenty[j])
}
}

//Please complete the second 'for' loop to print the array elements.
-Output is correct but I cant able to submit and move forward
by

2 Answers

iamabhishek
Try this code:

package main
import "fmt"

func main() {
var listOfTwenty [20] int
for i := 0; i < 20; i++ {
listOfTwenty[i] = i+1
}
fmt.Println("Here is the list of 20 numbers:")
for j := 0; j < 20; j++ {
fmt.Println(listOfTwenty[j])
}
}
Udaykirangvhft
Thank you, sir its working now

Login / Signup to Answer the Question.