Check if a given number is Even or Odd

Special Numbers Conditions Posted May 09, 2020

Any number which is divisible by 2 is called as an Even number, and any number which is not divisible by 2 is called an Odd number. Examples of Even numbers are all multiples of 2 such as 2,4,6,8,10 .. and Odd numbers are 1,3,5,7,9,..

        public static string IsEvenOrOdd(int n)
            if (n % 2 == 0)
                return "EVEN";
                return "ODD";

How it works:

For any given number, we divide the number by two and check the reminder. If the remainder is 0, then it means that the number is Even otherwise Odd.

We use cookies to provide you with a great user experience, analyze traffic and serve targeted promotions.   Learn More   Accept