Skip to content

Instantly share code, notes, and snippets.

@hi-manshu
Last active July 12, 2018 16:00
Show Gist options
  • Save hi-manshu/103058cc704cfd850db31117ad0bcbdc to your computer and use it in GitHub Desktop.
Save hi-manshu/103058cc704cfd850db31117ad0bcbdc to your computer and use it in GitHub Desktop.
package main
//imported the package fmt
import "fmt"
func main() {
//main function gets called when the program runs
// declared the first variable with datatype int
var firstNumber int = 10
// declared the second variable without any datatype
var secondNumber = 20
// declared the third variable without any datatype and keyword Var
thirdNumber := 30
additionOfThreeNumbers := firstNumber + secondNumber + thirdNumber
//will display the result of the addition in terminal
fmt.Println(additionOfThreeNumbers)
if additionOfThreeNumbers < 0 {
fmt.Println("The Addition is Negative")
} else if additionOfThreeNumbers == 0 {
fmt.Println("The Addition is equals to Zero")
} else {
fmt.Println("The Addition is Positive")
}
}
>>go run if.go
>>60
>>The Addition is Positive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment