In this example program, We will find quotient and remainder from the given numerator(dividend) and denominator(divisor) using modulus and division operator in Golang.

The

the

The

__quotient__is a result of the division operator in mathematics. In golang division operator / is used and applied to integers.the

__remainder__is a result of modulus operator in mathematics. % symbol is defined in Golang.### Example: Find Quotient and Remainder

The below example explains about golang arithmetic operators- Division operator - Divide the numerator with the denominator
- Modulus operator - Output remainder for the result of the division operator

*example of Division and modulus operator in Golang*```
package main
import (
"fmt"
)
func main() {
numerator := 40
denominator := 20
/*quotient := numerator / denominator
remainder := numerator % denominator */
// above commented code can be replaced with single line as below
quotient, remainder := numerator/denominator, numerator%denominator
fmt.Println("quotient result:", quotient)
fmt.Print("remainder result:", remainder)
}
```

The output of the above program is```
quotient result: 2
remainder result:0
```

In the above example, Two integer numbers 40(numerator) and 20(denominator) are stored in a variable - numerator, and denominator.

40 is divided by 20 using / Operator. and result is stored in the quotient variable. the remainder of 40/20 is 0, stored in remainder variable.

Both quotient and remainder variables values are printed to console using fmt println function.

EmoticonEmoticon