×

Go Tutorial

Go Basics

Go Variables

Go Literals

Go Type Handling

Go Operators

Go Decision Making

Go Loops

Go Functions

Go String

Go Arrays

Go Slices

Go Maps

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

Golang Arithmetic Operators

Last Updated : April 19, 2025

Arithmetic or Mathematical operators are used to perform mathematic operations such as addition, subtraction, multiplication, etc.

List of Arithmetic Operators

Operator Description Example
x:=5
y:=2
Addition (+) Adds two operands x+y returns 7
Subtraction (-) Subtracts two operands (subtracts the seconds operand from the first operand) x-y returns 3
Multiplication (*) Multiplies two operands x*y returns 10
Division (/) Divides the first operand with the second operand and returns the result x/y returns 2
Modulus (%) Returns the remainder of two operands x%y returns 1
Increment (++) Increases the value of the variable by one x++ returns 6
Decrement (--) Decreases the value of the variable by one x-- returns 4

Example of Arithmetic Operators

The below Golang program is demonstrating the example of arithmetic operators.

// Golang program demonstrate the
// example of arithmetic operators

package main

import "fmt"

func main() {
	x := 5
	y := 2
	result := 0

	result = x + y
	fmt.Println(x, "+", y, "=", result)

	result = x - y
	fmt.Println(x, "-", y, "=", result)

	result = x * y
	fmt.Println(x, "*", y, "=", result)

	result = x / y
	fmt.Println(x, "/", y, "=", result)

	result = x % y
	fmt.Println(x, "%", y, "=", result)

	x++
	fmt.Println("x++ =", x)

	y--
	fmt.Println("y-- =", y)
}

Output:

5 + 2 = 7
5 - 2 = 3
5 * 2 = 10
5 / 2 = 2
5 % 2 = 1
x++ = 6
y-- = 1

Go Arithmetic Operators Exercise

Select the correct option to complete each statement about arithmetic operators in Go.

  1. The operator ___ is used to perform addition in Go.
  2. In Go, the ___ operator is used to perform division.
  3. The operator ___ is used to get the remainder of a division in Go.

Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.