April 15, 2020

How to write a program to find even or odd number in C#

Write a program to identify whether the number entered by a user is even or odd.



How to write a program to find even or odd number in C#


Sample Solution

C# Sharp Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
 static void Main(string[] args)
  {
   int n1;
   Console.WriteLine("Enter a Number");
   n1 = Convert.ToInt32(Console.ReadLine());
   if (n1 % 2 == 0)
   {
   Console.WriteLine("you number have Entered is an Event");
   }
   else
  {
  Console.WriteLine("you number have Entered is an odd");
 }
  Console.ReadLine();
        }
    }
}

                                                                Sample Output

Write a program to identify whether the number entered by a user is even or odd




No comments:

Post a Comment