Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import "fmt"
- func main() {
- var num1, num2 int
- fmt.Scanln(&num1)
- fmt.Scanln(&num2)
- var symbol string
- fmt.Scanln(&symbol)
- var number = ""
- if (symbol == "+" || symbol == "-" || symbol == "*") {
- var sum = 0
- if (symbol == "+") {
- sum = num1 + num2
- } else if (symbol == "-") {
- sum = num1 - num2
- } else {
- sum = num1 * num2
- }
- if (sum % 2 == 0) {
- number = "even"
- } else {
- number = "odd"
- }
- fmt.Printf("%d %s %d = %d - %s\n", num1, symbol, num2, sum, number)
- } else {
- if (num2 == 0) {
- fmt.Printf("Cannot divide %d by zero", num1)
- } else {
- if (symbol == "/") {
- fmt.Printf("%d / %d = %.2f\n", num1, num2, float64(num1) / float64(num2))
- } else if (symbol == "%") {
- fmt.Printf("%d %% %d = %d\n", num1, num2, num1 % num2)
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement