Write C# Program to check whether entered number is odd or even

Introduction

Write C# Program to check whether entered number is odd or even. I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
 
namespace csharpprograms
{
    class Program
    {
        static void Main(string[] args)
        {
            int number;            
            Console.WriteLine("Enter a number: ");
            number = Convert.ToInt32(Console.ReadLine());
 
            // Even number if remainder is 0
            if (number % 2 == 0)
                Console.WriteLine("Entered Number is an Even Number");                
            else
                Console.WriteLine("Entered Number is odd Number");
 
            Console.ReadLine();
 
        }
    }
}

Result

Write C# Program to check whether entered number is odd or even
Write C# Program to check whether entered number is odd or even

Leave a Comment

x