Go Logical Operators

Gayathri. B

 Logical Operators

  • Logical operators are used to evaluate the relationship between two or more conditions or expressions. They return a Boolean value (true or false) based on the logic applied.


Example:

package main
import "fmt"
func main() {
  x := 5
  y := 10
  fmt.Println(x > 3 && y < 15)  // true  (both are true)
  fmt.Println(x > 6 || y < 15)  // true  (one condition is true)
  fmt.Println(!(x > 6))         // true  (x > 6 is false, NOT false is true)
}
Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send