GO supports the standard arithmetic operators: (Addition, Subtraction, Multiplication, Division,Remainder)


Basic GO program to display of standard arithmetic operators with 2 integer values.It contains the main package line, the fmt import line, and the main function declaration, and it uses the Println function.

Example

package main

import "fmt"

func main() {
	fmt.Println("1 + 2 = ",1+2)      // Addition
	fmt.Println("5 * 2 = ",5*2)       // Multiplication
	fmt.Println("10 - 2 = ",10-2)   // Subtraction
	fmt.Println("10 / 2 = ",10/2)    // Division
	fmt.Println("10 % 2 = ",10%2)   // Remainder
}
This small set of basic operators, along with some of the helper functions available in the math package, is sufficient to create surprisingly sophisticated programs.
Most Helpful This Week