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

Level 6. Question 1 whats the solution

i wrote the following code for this

package main
import "fmt"

func takeABreak() {
fmt.Println("Yeah! It's my break time.")
}
func main() {
for i:=12%4; i<=12; i+=4 {
if (i == 0) {
takeABreak()
}
if (i == 4) {
takeABreak()
}
if (i == 8) {
takeABreak()
}
}
}

what's the answer
by

1 Answer

sam5epi0l
Hey, you need to use single if block for this one inside for loop.


package main
import "fmt"

func takeABreak() {
fmt.Println("Yeah! It's my break time.")
}
func main() {
for i:=1; i<=12; i++ {
if i % 4 == 0 {
takeABreak()
}
}
}

Login / Signup to Answer the Question.