C# program which checks whether the number you inputted is an Even or Odd number
C# program which checks whether the number you inputted is an Even or Odd number.
Object:
C# Program Make a class EvenODD, which checks whether the number you inputted is an Even or Odd number. C# Projects with Source Code
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Lab_3
{
class Ev_odd
{
public void evo()
{
int num1, num2;
Console.WriteLine(“Please Enter Any Number Check Even or odd.”);
num1 = Convert.ToInt32(Console.ReadLine());
num2 = num1 % 2;
if (num2 == 0)
Console.WriteLine(“\n{0} is Even Number.”, num1);
else
Console.WriteLine(“\n{0} is odd Number.”, num1);
}
}
class Program
{
static void Main()
{
Ev_odd i = new Ev_odd();
i.evo();
Console.ReadKey();
}
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Lab_3 { class Ev_odd { public void evo() { int num1, num2; Console.WriteLine("Please Enter Any Number Check Even or odd."); num1 = Convert.ToInt32(Console.ReadLine()); num2 = num1 % 2; if (num2 == 0) Console.WriteLine("\n{0} is Even Number.", num1); else Console.WriteLine("\n{0} is odd Number.", num1); } } class Program { static void Main() { Ev_odd i = new Ev_odd(); i.evo(); Console.ReadKey(); } } } |