# Simple Arithmetical Operations

## A fast review of operators in C# followed by a number of simple Code Hunt Code Duels for practice.

programmingCodeHunt

# Simple Arithmetical Operations

Created 3 years ago

Duration 0:04:16
35
A fast review of operators in C# followed by a number of simple Code Hunt Code Duels for practice.
Slide Content

2. ### Slide 2 - Mathematical Operators

• Operator
• +
• -
• *
• /
• %
• ++
• --
• +=, -=, *=, /=
• Meaning
• Subtract
• Multiply
• Divide
• Remainder (Modulus)
• Increment
• Decrement
• Similar to x = x operator y
3. ### Slide 3 - Modulus or Remainder Operator %

• Returns the integer remainder of an integer division operation
• 5 % 2 results in a value of 1 One is the remainder when 5 is divided by 2
• 6 % 3 results in a value of 0 Six is evenly divided by three so there is a remainder of zero
• 13 % 5 results in a value of 3 13 / 5 is 2 with a remainder of 3
4. ### Slide 4 - ++ and – the before and after

• Increment
• X++ Uses the current value of X and then adds one to the value of X
• ++X Adds one to the value of X and then uses the new value
• Decrement
• X-- Uses the current value of X and then subtracts one from the value of X
• --X Subtracts one from the value of X and then uses the new value

• Long Form
• x= x + 5;
• x= x – 5;
• x= x * 5;
• x= x / 5;
• Short Form
• X += 5;
• X -= 5;
• X *= 5;
• X /= 5;
6. ### Slide 6 - Let’s Start With the Code Hunt Puzzles

• Click on the Capture Code button to test the code