From 5cd250b96e5432602b47db862c27ddbaf2e88aac Mon Sep 17 00:00:00 2001 From: Boukabouya Date: Sun, 31 Dec 2023 05:54:23 +0100 Subject: [PATCH] Program conditional logic --- hello/main.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/hello/main.go b/hello/main.go index 8ab932f..fc63da7 100644 --- a/hello/main.go +++ b/hello/main.go @@ -5,5 +5,25 @@ import ( ) func main() { - fmt.Println("Hello from Go!") + fmt.Println("Program conditional logic") + theAns := 42 + var result string + if theAns < 0 { + result = "The result is less than 0" + } else if theAns == 0 { + result = "The result null " + } else { + result = "The result is Greater than 0" + } + fmt.Println(result) + + if x := -42; x < 0 { + result = "The result is less than 0" + } else if x == 0 { + result = "The result null " + } else { + result = "The result is Greater than 0" + } + fmt.Println(result) + }