Answers for "golang while loops with for loops"

Go
4

golang loop

package main

import "fmt"

func main() {
	sum := 0
	for i := 0; i < 10; i++ {
		sum += i
	}
	fmt.Println(sum)
}
Posted by: Guest on March-26-2020
0

while in golang

package main

import "fmt"

func main() {
	sum := 1
	for sum < 10 {
	 fmt.Println(sum)
	 sum++
	}	
}
Posted by: Guest on April-17-2021

Browse Popular Code Answers by Language