Go Relational Operators

Go Language - Relational operators

Relational operators compare two operands and returns a boolean value.

go-language-relational-operators

Example :

CODE/PROGRAM/EXAMPLE
package main
import "fmt"
func main() {
	a := 45
	b := 40
	if(a>b){		/* Relational or comparison Operators*/
	fmt.Printf("True when a is greater\n" )
	}
	if(b < a){
		fmt.Printf("True when b is lesser\n" )
		}
		if(b!=a){
			fmt.Printf("True when both a and b are not equal\n" )
			}
			b=45
			if(b==a){
				fmt.Printf("True when both a and b are equal\n" )
				}
				}
				
Output:
True when a is greater
True when b is lesser
True when both a and b are not equal
True when both a and b are equal

Bitwise operators :

Bitwise operators perform bit-by-bit operation and works on bits.

go-language-bitwise-operators

Example :

CODE/PROGRAM/EXAMPLE
package main
import "fmt"
func main() {	/* Bitwise operators examples*/
var a uint = 10
var b uint = 4
var c uint =   2
c = a & b
fmt.Printf("Value of c is %d\n", c )
c = a | b
fmt.Printf("Value of c is %d\n", c )
c = a ^ b
fmt.Printf("Value of c is %d\n", c )
c = a << 2
fmt.Printf("Value of c is %d\n", c )
c = a >> 2
fmt.Printf("Value of c is %d\n", c )
}

Output : Value of c is 0
Value of c is 14
Value of c is 14
Value of c is 40
Value of c is 2
#golang_Relational_operators #go_language_relational_operator #golang_relational_operator_example #

(New page will open, for Comment)

Not yet commented...