Goto loop

Report a typo

Write the code where you get a number and print out the sum of every even element from zero to the given number using the goto statement (without using loops).

Sample Input 1:

1

Sample Output 1:

0
Write a program in Go
package main

import "fmt"

func main() {
var i, num, sum int
fmt.Scan(&num)

?:
if i%2 == 0 {
sum += ?
}
i++
if i <= num {
goto ?
}

fmt.Println(?)
}
___

Create a free account to access the full topic