0
0
Goprogramming~10 mins

Continue statement in Go - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to skip printing the number 3 in the loop.

Go
for i := 1; i <= 5; i++ {
    if i == 3 {
        [1]
    }
    fmt.Println(i)
}
Drag options to blanks, or click blank then click option'
Acontinue
Bgoto
Cbreak
Dreturn
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using break will exit the loop entirely.
Using return will exit the function, not just skip iteration.
2fill in blank
medium

Complete the code to skip even numbers when printing from 1 to 6.

Go
for i := 1; i <= 6; i++ {
    if i%2 == 0 {
        [1]
    }
    fmt.Println(i)
}
Drag options to blanks, or click blank then click option'
Abreak
Bcontinue
Cexit
Dstop
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using break will stop the entire loop early.
Using exit or stop are not valid Go statements.
3fill in blank
hard

Fix the error in the loop to skip printing negative numbers.

Go
numbers := []int{2, -1, 3, -4, 5}
for _, num := range numbers {
    if num < 0 {
        [1]
    }
    fmt.Println(num)
}
Drag options to blanks, or click blank then click option'
Areturn
Bbreak
Ccontinue
Dskip
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using break will stop the loop completely.
Using skip is not a valid Go statement.
4fill in blank
hard

Fill both blanks to skip printing numbers divisible by 3 in the loop.

Go
for i := 1; i <= 10; i++ {
    if i [1] 3 == 0 {
        [2]
    }
    fmt.Println(i)
}
Drag options to blanks, or click blank then click option'
A%
Bbreak
Ccontinue
D==
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using break will stop the loop entirely.
Using == instead of % will cause a logic error.
5fill in blank
hard

Fill all three blanks to skip printing words shorter than 4 letters and convert others to uppercase.

Go
words := []string{"go", "code", "fun", "learn"}
for _, word := range words {
    if len(word) [1] 3 {
        [2]
    }
    fmt.Println([3])
}
Drag options to blanks, or click blank then click option'
A<=
Bcontinue
Cstrings.ToUpper(word)
D==
Attempts:
3 left
๐Ÿ’ก Hint
Common Mistakes
Using == instead of <= will miss some short words.
Printing word without conversion does not meet the requirement.