even or odd number in C#

 

For Example: Program to demonstrate use of if-else statement find out given number is even   or odd   .

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

 

namespace ConsoleApplication1

{

class Program

    {

static void Main(string[] args)

        {

int a;

Console.WriteLine("Enter any number");

a = Convert.ToInt32(System.Console.ReadLine());

if (a%2==0)

            {

Console.WriteLine("Given Number is even");

Console.ReadLine();

            }

else

            {

Console.WriteLine("Given Number is odd");

Console.ReadLine();

            }

 

        }

    }

}

Output:

Comments

Popular posts from this blog

simple program C#

Regular Expression Validator Control in asp.net

two dimension array in C#