Exercise: calculator
Write a command-line calculator that works with the 4 basic operators +-*/
like this:
$ go run cacl.go 3 + 4
7
$ go run calc.go 8 / 2
4
- Does multiplication also work?
- What happens if we try to divide by 0?
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Write a command-line calculator that works with the 4 basic operators +-*/
like this:
$ go run cacl.go 3 + 4
7
$ go run calc.go 8 / 2
4