Q:

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

0

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

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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:

Enter a number: 

20

Entered Number is an Even Number

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C# Program to Find the Largest Number Among ... >>