Related Tags

golang
arithmetic
go

# What are arithmetic operators in Golang? Educative Team

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.

### Operators

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.

### Arithmetic operators

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.

### Example

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)

}
The implementation of arithmetic operators by assigning parameters

### Explanation

• Line 8: We assign the value, 10, to the variable a.
• Line 9: We assign the value, 8, to the variable b.
• Line 11: This is the syntax to add a and b.
• Line 14: This is the syntax to subtract a and b.
• Line 17: This is the syntax to multiply a and b.
• Line 20: This is the syntax to divide a and b.
• Line 23: This is the syntax to find the remainder of a and b.
• Line 26: This is the value of a increased by one.
• Line 29: This is the value of b decreased by one.

RELATED TAGS

golang
arithmetic
go 