Go Program to print even numbers between 1 to 100


In this program, you will learn how to print even numbers between 1 to 100 in Go.


if i % 2 == 0 { 
   //statement 
}

Example: How to print even numbers between 1 to 100 in Go

package main
import "fmt"

func main() {

	for i := 1; i < 100; i++ {
		if i%2 == 0 {
			fmt.Println("Number is even:", i)
		}
	}
}

Output:

Number is even: 2
Number is even: 4
Number is even: 6
Number is even: 8
Number is even: 10
Number is even: 12
Number is even: 14
Number is even: 16
Number is even: 18
Number is even: 20
Number is even: 22
Number is even: 24
Number is even: 26
Number is even: 28
Number is even: 30
Number is even: 32
Number is even: 34
Number is even: 36
Number is even: 38
Number is even: 40
Number is even: 42
Number is even: 44
Number is even: 46
Number is even: 48
Number is even: 50
Number is even: 52
Number is even: 54
Number is even: 56
Number is even: 58
Number is even: 60
Number is even: 62
Number is even: 64
Number is even: 66
Number is even: 68
Number is even: 70
Number is even: 72
Number is even: 74
Number is even: 76
Number is even: 78
Number is even: 80
Number is even: 82
Number is even: 84
Number is even: 86
Number is even: 88
Number is even: 90
Number is even: 92
Number is even: 94
Number is even: 96
Number is even: 98

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.