Monday, 20 February 2017

even or odd program in c#

frequently asking logical program in interviews for dotnet fresher

Even or odd program
/*Even or odd program*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication85
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            Console.WriteLine("enter a number:");
            n = int.Parse(Console.ReadLine());
            if (n % 2 == 0)
            {
                Console.WriteLine("the entered no is even number");
                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("the entered number is odd number");
            }
        }
    }
}

output: screen shot










No comments:

Post a Comment