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();
}
}
}
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(); } } }
Output:
Another Program: How to Input any Number in C#
C++ projects for beginners with source code