Simple Arithmetical Operations
Created 2 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.

Embed

Social
Select the file type you wish to download
Slide Content
Tags:
programming
CodeHunt

Slide 1  Simple Arithmetical Operations

Slide 2  Mathematical Operators
 Operator
 +
 
 *
 /
 %
 ++
 
 +=, =, *=, /=
 Meaning
 Add
 Subtract
 Multiply
 Divide
 Remainder (Modulus)
 Increment
 Decrement
 Similar to x = x operator y

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

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

Slide 5  Fun with the Equals Sign
 Long Form
 x= x + 5;
 x= x – 5;
 x= x * 5;
 x= x / 5;
 Short Form
 X += 5;
 X = 5;
 X *= 5;
 X /= 5;

Slide 6  Let’s Start With the Code Hunt Puzzles
 Click on the Capture Code button to test the code