In this example, we will show you how to use arithmetic operators in Go with an example.
Go arithmetic operators
In this example, we use addition, subtraction, multiplication, division, and remainder operations.
package main
import "fmt"
func main() {
var a = 2
var b = 3
var c = 4
var add = a + b + c
var sb = c - a
var mult = a * b
var div = c / 2
var rem = c % a
fmt.Println(add)
fmt.Println(sb)
fmt.Println(mult)
fmt.Println(div)
fmt.Println(rem)
}
Output:
9 2 6 2 0
Free Spring Boot Tutorial - 5 Hours Full Course
Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course