## Arithmetic Operations

**The ‘+’ Operator:**

{

static void Main(string[] args)

{

//
Example 1:

int a = 5;

int b = 5;

int c = a + b;

//c = 10

//
Example 2:

int d = 5 + 3;

//d = 8

}

}

**The ‘-’ Operator:**

{

// Example 1:

int a = 5;

int b = 5;

int c = a - b;

//c = 0

//
Example 2:

int d = 5 - 3;

//d = 2

}

**The ‘/’ Operator:**

static void Main(string[] args)

{

//
Example 1:

int a = 25;

int b = 5;int c = a / b;

//c =

//
Example 2:

int d = 100 / 10;

//d = 10

}

**The ‘%’ Operator:**

static void Main(string[] args)

{

//
Example 1:

int a = 25;int b = 5;

int c = a % b;

//c = 0

//
Example 2:

int d = 100 % 9;

//d = 1

}

## Logical Operations

**F = False**

**T = True**

Variable name | A | B | A AND B (&&) | A OR B (||) |

Case 1 | F | F | F | F |

Case 2 | T | T | T | T |

Case 3 | F | T | F | T |

Case 4 | T | F | F | T |

**The ‘OR’ Operator:**

if ((a > b) || (a < c) )

{

//Use the '

**OR'**operation between two relational conditions
}

**The ‘AND’ Operator:**

if ((a > b) && (a < c))

{

//Use the

**'AND'**operation between 2 relational conditions
}

**The ‘True’ Operator:**

if ((a > b) == true)

{

//Perform operation if the condition return

**‘false’**
}

**The ‘False’ Operator:**

if ((a > b) == false )

{

//Perform operation if the condition return

**‘false’**
}

**The ‘!’ Operator:**

if (!(a > b))

{

//Perform operation if '

**a'**is not bigger then '**b'**
}

## Comparing Operations

**Operator**

**No'**

**1 – Equal (==):**

{

int a = 1;

int b = 2;

if (a == b)

{

//Perform operation if '

**a'**is Equal to**'b'**
}

}

**Operator**

**No'**

**2 – Smaller (<):**

class Program

{

static void Main(string[] args)

{

int a = 1;

int b = 2;

if (a < b)

{

//Perform operation if

} **'a'**is smaller then**'b'**}

}

**Operator**

**No'**

**3 – Bigger (>):**

{

static void Main(string[] args)

{

int a = 1;

int b = 2;

if (a > b)

{

//Perform operation if

**'a'**is bigger then**'b'**
}

}

}

**Operator**

**No'**

**4 – Bigger or Equal (>=):**

{

int a = 1;

int b = 2;

if (a >= b)

{

//Perform operation if **'a'**is Bigger Or Equal to

**'b'**

}

}

**Operator**

**No'**

**5 – Smaller or Equal (<=):**

{

int a = 1;

int b = 2;

if (a <= b)

{

//Perform operation if

**'a'**is Smaller Or Equal to**'b'**
}

}

**Operator No' 6 – Not Equal (! =):**

{

int a = 1

int b = 2;

if (a != b)

{

//Perform operation if

**'a'**is not Equal to**'b'**
}

}

## Shortcuts operations

This article will cover the assignments operators you can use to perform mathematical operation.**Operator**

**No'**

**1 (+=):**

**Full:**a = a + 5;

**Shortcut**

**:**a += 5;

**Operator**

**No'**

**2 (-=):**

**This operator can be used when you want to reduce a number from a variable**

**Full:**a = a - 5;

**Shortcut**

**:**a -= 5;

**Operator**

**No'**

**3 (*=):**

**Full:**a = a * 5;

**Shortcut**

**:**a *= 5;

**Operator**

**No'**

**4 (/=):**

**Full:**a = a / 5;

**Shortcut**

**:**a /= 5;

**Increment and Decrement operators**

**Increment Example:**

Y = y + 1;

Y++;

**Decrement Example:**

Using this operator will cause a degradation of -1 for the manipulated variable

Y = y - 1;

Y--;

**Note!**

## No comments:

## Post a Comment