Concept Flow - Arithmetic operators
Start
Initialize variables
Apply +, -, *, /, %
Store results
Print results
End
This flow shows how arithmetic operators take variables, perform calculations, store results, and then output them.
int a = 10; int b = 3; int sum = a + b; int diff = a - b; int prod = a * b; int div = a / b; int mod = a % b; printf("%d %d %d %d %d", sum, diff, prod, div, mod);
| Step | Operation | Expression | Result | Explanation |
|---|---|---|---|---|
| 1 | Addition | sum = a + b | 13 | 10 + 3 equals 13 |
| 2 | Subtraction | diff = a - b | 7 | 10 - 3 equals 7 |
| 3 | Multiplication | prod = a * b | 30 | 10 * 3 equals 30 |
| 4 | Division | div = a / b | 3 | Integer division 10 / 3 equals 3 (fraction discarded) |
| 5 | Modulo | mod = a % b | 1 | Remainder of 10 divided by 3 is 1 |
| 6 | printf(...) | 13 7 30 3 1 | Outputs all results separated by spaces | |
| 7 | End | - | - | Program finishes |
| Variable | Initial | After Step 1 | After Step 2 | After Step 3 | After Step 4 | After Step 5 | Final |
|---|---|---|---|---|---|---|---|
| a | 10 | 10 | 10 | 10 | 10 | 10 | 10 |
| b | 3 | 3 | 3 | 3 | 3 | 3 | 3 |
| sum | undefined | 13 | 13 | 13 | 13 | 13 | 13 |
| diff | undefined | undefined | 7 | 7 | 7 | 7 | 7 |
| prod | undefined | undefined | undefined | 30 | 30 | 30 | 30 |
| div | undefined | undefined | undefined | undefined | 3 | 3 | 3 |
| mod | undefined | undefined | undefined | undefined | undefined | 1 | 1 |
Arithmetic operators in C: + addition - subtraction * multiplication / integer division (fraction discarded) % modulo (remainder) Use with integers to calculate and store results.