In this article we
will discuss with you the program for testing a number for even and odd number
using console application in c#.net using :
Step1: Take a new console application using c# as
a language in the Visual studio.
Step2: Declare a variable “int_Number” for storing the value
for checking whether it is even or odd.
Step3: now take the modulo of 2 of that number, if
it result in zero that means it is even no otherwise it is odd no.
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
namespace No_is_Even_Odd
{
class Program
{
static void Main(string[]
args)
{
int
int_Number;
Console.WriteLine("please the numbers to be tested for even and odd
number");
int_Number = int.Parse(Console.ReadLine());
if
(int_Number % 2 == 0)
{
Console.WriteLine("Entered number is an Even number.");
}
else
{
Console.WriteLine("Entered number is an Odd number.");
}
Console.ReadLine();
}
}
}
Output
:
No comments:
Post a Comment