Search This Blog

Tuesday, May 13, 2014

Check number is even or odd C#

C# > Operators > % Operator

Computes the remainder after dividing its first operand by its second.

Example: Check number is even or odd


  for (int x = 0; x < 100; x++)
  {
     if (x % 2 == 0)
      //even number
     else
      //odd number

  }