Bird
Raised Fist0
C Sharp (C#)programming~5 mins

Arithmetic operators in C Sharp (C#) - Cheat Sheet & Quick Revision

Choose your learning style10 modes available
Recall & Review
beginner
What are arithmetic operators in C#?
Arithmetic operators are symbols used to perform basic math operations like addition (+), subtraction (-), multiplication (*), division (/), and modulus (%).
Click to reveal answer
beginner
What does the modulus operator (%) do?
The modulus operator (%) gives the remainder after dividing one number by another. For example, 7 % 3 equals 1 because 7 divided by 3 leaves a remainder of 1.
Click to reveal answer
beginner
How does integer division behave in C#?
When you divide two integers, C# returns the whole number part only, dropping any decimal. For example, 7 / 3 equals 2, not 2.333.
Click to reveal answer
intermediate
What is the result of this C# expression: 5 + 3 * 2?
The result is 11 because multiplication (*) has higher priority than addition (+). So, 3 * 2 = 6, then 5 + 6 = 11.
Click to reveal answer
beginner
Explain the difference between / and % operators in C#.
The / operator divides two numbers and returns the quotient (the result of division). The % operator returns the remainder left after division. For example, 10 / 3 is 3, and 10 % 3 is 1.
Click to reveal answer
What is the output of: int result = 10 / 4; Console.WriteLine(result); ?
A2
B2.5
C3
D4
Which operator gives the remainder of a division in C#?
A+
B-
C/
D%
What is the result of: 8 + 2 * 5?
A20
B18
C50
D30
Which operator is used for multiplication in C#?
A*
B/
C+
D-
What will be the output of: Console.WriteLine(15 % 4); ?
A1
B4
C3
D15
Describe the main arithmetic operators in C# and give a simple example for each.
Think about +, -, *, /, and % symbols.
You got /6 concepts.
    Explain how operator precedence affects the result of arithmetic expressions in C#.
    Consider how 5 + 3 * 2 is calculated.
    You got /4 concepts.

      Practice

      (1/5)
      1. Which arithmetic operator in C# is used to find the remainder of a division?
      easy
      A. -
      B. /
      C. *
      D. %

      Solution

      1. Step 1: Understand the purpose of each operator

        The % operator returns the remainder after division, while / divides, * multiplies, and - subtracts.
      2. Step 2: Identify the operator for remainder

        The operator that gives the remainder is %.
      3. Final Answer:

        % -> Option D
      4. Quick Check:

        Remainder operator = % [OK]
      Hint: Remainder uses % symbol, like dividing candies leftover [OK]
      Common Mistakes:
      • Confusing / (division) with % (remainder)
      • Using * or - instead of %
      • Thinking % is modulus function
      2. Which of the following is the correct syntax to multiply two integers a and b in C#?
      easy
      A. int result = a + b;
      B. int result = a * b;
      C. int result = a & b;
      D. int result = a x b;

      Solution

      1. Step 1: Recall multiplication operator in C#

        Multiplication uses the asterisk symbol * between operands.
      2. Step 2: Check each option's syntax

        int result = a * b; uses * 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.
      3. Final Answer:

        int result = a * b; -> Option B
      4. Quick Check:

        Multiplication operator = * [OK]
      Hint: Use * for multiply, not x or & [OK]
      Common Mistakes:
      • Using x instead of *
      • Using & thinking it's multiply
      • Confusing + with *
      3. What is the output of the following C# code?
      int a = 7;
      int b = 3;
      Console.WriteLine(a / b);
      medium
      A. 2
      B. 2.3333333
      C. 3
      D. 1

      Solution

      1. Step 1: Understand integer division in C#

        Both a and b are integers, so division a / b performs integer division, dropping decimals.
      2. Step 2: Calculate integer division result

        7 divided by 3 is 2.333..., but integer division truncates to 2.
      3. Final Answer:

        2 -> Option A
      4. Quick Check:

        Integer division truncates decimals = 2 [OK]
      Hint: Integer division drops decimals, so 7/3 = 2 [OK]
      Common Mistakes:
      • Expecting decimal result
      • Confusing integer division with float division
      • Using wrong operator
      4. Identify the error in this C# code snippet:
      int x = 10;
      int y = 0;
      int z = x / y;
      Console.WriteLine(z);
      medium
      A. Variable z is not declared
      B. Missing semicolon after Console.WriteLine
      C. Division by zero causes runtime error
      D. x and y must be floats for division

      Solution

      1. Step 1: Analyze division operation

        The code divides x by y, where y is zero.
      2. Step 2: Understand division by zero in C#

        Dividing an integer by zero causes a runtime error (DivideByZeroException).
      3. Final Answer:

        Division by zero causes runtime error -> Option C
      4. Quick Check:

        Division by zero throws error [OK]
      Hint: Never divide by zero; it crashes your program [OK]
      Common Mistakes:
      • Ignoring division by zero error
      • Thinking missing semicolon causes error
      • Assuming float needed for division
      5. You want to calculate the average of two integers a and b in C#. Which expression correctly computes the average as a floating-point number?
      hard
      A. (a + b) / 2.0
      B. (a + b) / 2
      C. a / 2 + b / 2
      D. (float)((a + b) / 2)

      Solution

      1. Step 1: Understand integer vs floating-point division

        Using only integers causes integer division, dropping decimals.
      2. Step 2: Check each option for floating-point division

        (a + b) / 2 divides integers, result is integer. (a + b) / 2.0 divides by 2.0 (double), so result is floating-point. a / 2 + b / 2 divides separately then adds, but integer division truncates each part. (float)((a + b) / 2) first performs integer division (a + b) / 2 truncating to integer, then casts to float, resulting in incorrect average due to truncation.
      3. Final Answer:

        (a + b) / 2.0 -> Option A
      4. Quick Check:

        Divide by 2.0 for float average [OK]
      Hint: Divide by 2.0 (double) to get float average, not int [OK]
      Common Mistakes:
      • Using integer division dropping decimals
      • Adding halves separately causing truncation
      • Casting after division instead of before
      Recommended

      Ready to prove it?

      Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

      10 questions~5 mineasy hard