# Golang Relational Operators

Here, we are going to learn about the Relational Operators in the Go programming language with examples.
Submitted by IncludeHelp, on December 07, 2021

## Relational Operators

Relational operators are used for making decisions, they are used to compare the expressions such as greater than, less than, equal to, etc. Relational operators return the Boolean value i.e., true or false.

## List of Golang Relational Operators

Operator Description Example
x:=5
y:=2
Equal To (==) Returns true if the values of both operands are equal; false, otherwise. x==y returns false
Not Equal To (!=) Returns true if the values of both operands are not equal; true, otherwise. x!=y returns true
Greater Than (>) Returns true if the value of the first operand is greater than the second operator; false, otherwise. x>y returns true
Less Than (<) Returns true if the value of the first operand is less than the second operator; false, otherwise. x<y returns false
Greater Than or Equal To (>=) Returns true if the value of the first operand is greater than or equal to the second operator; false, otherwise. x>=y returns true
Less Than or Equal To (<=) Returns true if the value of the first operand is less than or equal to the second operator; false, otherwise. x<=y returns false

## Example of Golang Relational Operators

The below Golang program is demonstrating the example of relational operators.

```// Golang program demonstrate the
// example of relational operators

package main

import "fmt"

func main() {
x := 5
y := 2
var result bool

result = x == y
fmt.Println(x, "==", y, "=", result)

result = x != y
fmt.Println(x, "!=", y, "=", result)

result = x < y
fmt.Println(x, "<", y, "=", result)

result = x > y
fmt.Println(x, ">", y, "=", result)

result = x >= y
fmt.Println(x, ">=", y, "=", result)

result = x <= y
fmt.Println(x, "<=", y, "=", result)
}
```

Output:

```5 == 2 = false
5 != 2 = true
5 < 2 = false
5 > 2 = true
5 >= 2 = true
5 <= 2 = false
```

Preparation

What's New

Top Interview Coding Problems/Challenges!