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 main import ( "fmt" ) func main() { a := 10 b := 8 var sum = a + b fmt.Println(sum) var diff = a - b fmt.Println(diff) var product = a * b fmt.Println(product) var division = a/b fmt.Println(division) var module = a%b fmt.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.RELATED TAGS
View all Courses