Concept Flow - Arithmetic operators
Start
Read operands
Choose operator (+, -, *, /, %)
Perform calculation
Store/Display result
End
This flow shows how arithmetic operators take two numbers, perform the chosen operation, and produce a result.
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;
| Step | Operation | Operands | Calculation | Result |
|---|---|---|---|---|
| 1 | Addition | a=10, b=3 | 10 + 3 | 13 |
| 2 | Subtraction | a=10, b=3 | 10 - 3 | 7 |
| 3 | Multiplication | a=10, b=3 | 10 * 3 | 30 |
| 4 | Division | a=10, b=3 | 10 / 3 | 3 (integer division) |
| 5 | Modulo | a=10, b=3 | 10 % 3 | 1 |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | After Step 4 | After Step 5 |
|---|---|---|---|---|---|---|
| a | 10 | 10 | 10 | 10 | 10 | 10 |
| b | 3 | 3 | 3 | 3 | 3 | 3 |
| sum | undefined | 13 | 13 | 13 | 13 | 13 |
| diff | undefined | undefined | 7 | 7 | 7 | 7 |
| prod | undefined | undefined | undefined | 30 | 30 | 30 |
| div | undefined | undefined | undefined | undefined | 3 | 3 |
| mod | undefined | undefined | undefined | undefined | undefined | 1 |
Arithmetic operators in C#: + addition - subtraction * multiplication / division (integer if both operands int) % modulo (remainder) Operands must be numbers; integer division discards decimals.
% operator returns the remainder after division, while / divides, * multiplies, and - subtracts.%.a and b in C#?* between operands.* correctly. int result = a x b; uses x which is invalid. int result = a & b; uses & which is bitwise AND, not multiplication. int result = a + b; uses + which is addition.int a = 7; int b = 3; Console.WriteLine(a / b);
a and b are integers, so division a / b performs integer division, dropping decimals.int x = 10; int y = 0; int z = x / y; Console.WriteLine(z);
x by y, where y is zero.a and b in C#. Which expression correctly computes the average as a floating-point number?Pass the test and this pattern moves unknown