Golang, also known as Go, is an open-source, compiled, and statically-typed programming language developed by Google. The language has a simple syntax and robust standard libraries.
It is used in real-world applications and supports imperative and OOP paradigms.
An operator is a symbol or function that indicates an operation. In Go, arithmetic operators perform just as they do in mathematics. They can be used as a calculator in Go.
Here are some common arithmetic operators:
x+y
: This provides the sum of two variables, x
and y
.
x-y
: This provides the difference between x
and y
.
x*y
: This provides the product of x
and y
.
x/y
: This provides the quotient of x
and y
.
x%y
: This provides the remainder of x
and y
after division.
x++
: The value of x
is increased by one.
x--
: The value of x
is decreased by one.
package mainimport ("fmt")func main() {a := 10b := 8var sum = a + bfmt.Println(sum)var diff = a - bfmt.Println(diff)var product = a * bfmt.Println(product)var division = a/bfmt.Println(division)var module = a%bfmt.Println(module)a++fmt.Println(a)b--fmt.Println(b)}
10
, to the variable a
.8
, to the variable b
.a
and b
.a
and b
.a
and b
.a
and b
.a
and b
.a
increased by one.b
decreased by one.Free Resources