Created
December 9, 2016 02:18
-
-
Save hygull/f8810d4f6e56bc4e2e277b33313ae9a0 to your computer and use it in GitHub Desktop.
operator precedence created by hygull - https://repl.it/Eg5w/4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
@Date of creation : 06 Dec 2016. | |
@Aim of program : Checking operator precedence. | |
@Coded by : Rishikesh Agrawani. | |
*/ | |
package main | |
import "fmt" | |
func main(){ | |
expIntVal:=2-3+4 //3 or -5 | |
fmt.Println(expIntVal) //3...Don't follow BODMAS Rule here as no parenthesis/brackets/braces are there...Just evaluate from Left -> Right as operators are of same precedence | |
expBoolVal:= 10<4 && 0>1 //Relatinal operators are executing before logical operator | |
println(expBoolVal) //false AND false -> false | |
expBoolVal= 10<4 && 0<1 | |
fmt.Printf("%t",expBoolVal) //false AND true -> false | |
expBoolVal= 10>4 && 0>1 | |
fmt.Printf("%t",expBoolVal) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment