How to Verify EVEN or ODD Number Using C#

In this tutorial, let’s learn how to verify the Even or Odd number using C#. This is just a simple program that you can easily understand and work on. For verifying whether the number is an Even or Odd, all you have to do is simply input any number that you like then press ENTER to execute the program and the result will tell you if it’s an Even or Odd number.

Creating Console Application

Step 1

Open Microsoft Visual Studio 2015 and create a new console application in c#. consoleps321

Step 2

Create a code to verify the EVEN and ODD number.
  1. int n;
  2. Console.Write("Input a Number : ");
  3. n = int.Parse(Console.ReadLine());
  4. if (n % 2 == 0)
  5. {
  6. Console.Write("The Number " + n + " is an Even Number");
  7. Console.Read();
  8. }
  9. else
  10. {
  11. Console.Write("The Number " + n + " is an Odd Number");
  12. Console.Read();
  13. }
Full source code.
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n;
  14. Console.Write("Input a Number : ");
  15. n = int.Parse(Console.ReadLine());
  16. if (n % 2 == 0)
  17. {
  18. Console.Write("The Number " + n + " is an Even Number");
  19. Console.Read();
  20. }
  21. else
  22. {
  23. Console.Write("The Number " + n + " is an Odd Number");
  24. Console.Read();
  25. }
  26. }
  27. }
  28. }
For any questions about this article. You can contact me @ Email – [email protected] Mobile No. – 09305235027 – TNT Or feel free to comment below.

Add new comment