Last active
July 12, 2018 16:00
-
-
Save hi-manshu/103058cc704cfd850db31117ad0bcbdc to your computer and use it in GitHub Desktop.
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
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