Concept Flow - Arithmetic operators
Start
Initialize variables
Apply operator: +, -, *, /, %
Store result
Use or print result
End
This flow shows how arithmetic operators take values, perform calculations, and produce results step-by-step.
package main import "fmt" func main() { a, b := 10, 3 result := a + b fmt.Println(result) result = a - b fmt.Println(result) result = a * b fmt.Println(result) result = a / b fmt.Println(result) result = a % b fmt.Println(result) }
| Step | Operation | Operands | Result | Explanation |
|---|---|---|---|---|
| 1 | Addition | 10 + 3 | 13 | Adds 10 and 3 to get 13 |
| 2 | Subtraction | 10 - 3 | 7 | Subtracts 3 from 10 to get 7 |
| 3 | Multiplication | 10 * 3 | 30 | Multiplies 10 by 3 to get 30 |
| 4 | Division | 10 / 3 | 3 | Divides 10 by 3, integer division truncates to 3 |
| 5 | Modulo | 10 % 3 | 1 | Remainder of 10 divided by 3 is 1 |
| 6 | End | - | - | All operations done, program ends |
| Variable | Start | After Addition | After Subtraction | After Multiplication | After Division | After Modulo | Final |
|---|---|---|---|---|---|---|---|
| a | 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| b | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| result | - | 13 | 7 | 30 | 3 | 1 | 1 |
Arithmetic operators in Go: Use + for addition, - for subtraction, * for multiplication, / for integer division, % for remainder (modulo). Integer division drops decimals. Example: 10 / 3 = 3, 10 % 3 = 1.