This post contains a total of 12+ Hand-Picked C Sharp Odd-Even Checker Program Examples with Source Code. All the Odd-Even Checker programs are made using C Sharp Programming Language.
You can use the source code of these programs for educational purpose with credits to the original owner.
Related Posts
Click a Code to Copy it.
1. By NiKiπΈπ
Made by NiKiπΈπ. Simple C# Odd-Even Checker. Give a whole number ex. 645.. ( Source )
34 34 is an even number.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Odd_or_Even
{
class Program
{
static void Main(string[] args)
{
//Console.Write("Give a number");
/*int num;
num = int.Parse(Console.ReadLine());*/
string abc;
int num;
/* double num = Convert.ToDouble(Console.ReadLine());*/
abc = Console.ReadLine();
if (!Int32.TryParse(abc, out num)){
Console.WriteLine("Please give a whole number!");
}
else if (num % 2==0 && num !=0){
Console.WriteLine("{0} is an even number.",num);
}
else if (num == 0){
Console.WriteLine("hmmm... you are very tricky, zero is an even number.",num);
}
/* else if (num !=(int)num){
Console.WriteLine("This is not a whole number. Please give a whole number.");
}*/
else{
Console.WriteLine("{0} is an odd number.",num);
}
}
}
}
2. By Nikolay Aleksiev
Made by Nikolay Aleksiev. Basic program to check odd even. ( Source )
23 Entered number is odd
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class EvenOrOdd
{
static void Main(string[] args)
{
int x = Convert.ToInt32(Console.ReadLine());
if(x % 2 == 0)
{
Console.WriteLine("Entered number is even");
}else{
Console.WriteLine("Entered number is odd");
}
}
}
}
3. By Shahghasi Adil π π¦π«
Made by Shahghasi Adil π π¦π«. ( Source )
Enter a Number : 5 Entered Number is an Odd Number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int i;
Console.Write("Enter a Number : ");
i = int.Parse(Console.ReadLine());
if (i % 2 == 0)
{
Console.Write("Entered Number is an Even Number");
Console.Read();
}
else
{
Console.Write("Entered Number is an Odd Number");
Console.Read();
}
}
}
}
4. By Hippopotamusproduct
Made by Hippopotamusproduct. ( Source )
Enter a number! 10 10 is even!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
try {
Console.WriteLine("Enter a number!");
int number = Convert.ToInt32(Console.ReadLine());
if (number % 2 == 0) {
Console.WriteLine(number + " is even!");
} else {
Console.WriteLine(number + " is odd!");
}
} catch (Exception e) {
Console.WriteLine("There was an error!");
}
}
}
}
5. By Beverly Ag
Made by Beverly Ag. Enter a number to know if it’s even or odd. ( Source )
22 22 is an even number,because it is divisible by two(2).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
long unknownNum = Convert.ToInt64(Console.ReadLine());
if (unknownNum % 2 == 0){
Console.WriteLine("{0} is an even number,because it is divisible by two(2).\n\nHint:If a number ends with 0,2,4,6,7,8, then it is an even number!!! ^_^",unknownNum);
}
else{
Console.WriteLine("{0} is an odd number,because it is not divisible by two(2).\n\nHint:If a number doesn't end with 0,2,4,6,8, then it is an odd number!!! ^_^",unknownNum);
}
Console.WriteLine("\n\nThanks for viewing this code!!!\n\nStay Safe");
}
}
}
6. By Mikeul
Made by Mikeul. ( Source )
Enter a number: 11 11 is odd number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
// Enter a number.
Console.WriteLine("Enter a number: ");
int input = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("{0} is {1} number", input, (input & 1)== 0 ? "even": "odd");
/*if(input % 2 == 0)
{
Console.WriteLine("{0} is even number", input);
}
else
{
Console.WriteLine("{0} is odd number", input);
}*/
}
}
}
7. By Sofia S. Tkachenko
Made by Sofia S. Tkachenko. Odd-Even checker using c sharp. ( Source )
12 Odd: 0 2 4 6 8 10 12 Even: 1 3 5 7 9 11 Thx for running my code!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int x = Convert.ToInt32(Console.ReadLine());
int y;
Console.WriteLine("Odd: ");
for(y = 0;y<=x;y++){
if (y%2 != 0)
continue;
Console.WriteLine(y);
}
Console.WriteLine(" ");
Console.WriteLine("Even: ");
for(y = 0;y<=x;y++){
if (y%2 == 0)
continue;
Console.WriteLine(y);
}
Console.WriteLine(" ");
Console.WriteLine("Thx for running my code!");
}
}
}
8. By Mikeul
Made by Mikeul. Even or Odd number validator. ( Source )
14 14 is an even number True True
using System;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
// Take an input from the user.
int a = Convert.ToInt32(Console.ReadLine());
// Call the methods from EvenOrOdd class and user input as first parameter
// and then add the condition using lambda syntax (or you can use function if you'd like to).
// I prefer lambda syntax because it is easier and shorter.
EvenOrOdd.CheckNumber(a, x => x % 2 == 0);
// Or you can simply use Predicate<>
Predicate<int> isEven = even => even % 2 == 0;
Console.WriteLine(isEven(a));
// Or maybe use Func<>
Func<int, bool> IsEven = a => a % 2 == 0;
Console.WriteLine(IsEven(a));
}
}
// Declare the delegate with bool return type and int x as parameter.
delegate bool IsEven(int x);
// Create a class to store the Function. (You don't have to create a class for this).
class EvenOrOdd
{
// This function takes in 2 parameters, first is int x and the delegate.
public static void CheckNumber(int x, IsEven isEven)
{
// This is where the delegate comes to use.
// remember that the delegate takes an int parameter, so we pass x value as an arguments.
// And if it's an even number, it will print the following message.
if(isEven(x))
Console.WriteLine($"{x} is an even number");
// Else, print the following message.
else
Console.WriteLine($"{x} is an odd number");
}
}
/*
As you can see we don't hard code anything. This delegate is very useful to create a reusable class
and easier to maintain. And it looks cool xD
*/
}
9. By Jacky Setiawan
Made by Jacky Setiawan. ( Source )
3 odd
using System;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int x = int.Parse(Console.ReadLine());
Console.WriteLine((x%2==0) ? "even": "odd");
}
}
}
10. By Canny πΉπΏ
Made by Canny πΉπΏ. Bitwise AND to check Even and Odd. ( Source )
Enter any number to check: 34 34 is EVEN
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
int num;
Console.WriteLine("Enter any number to check: ");
num = Convert.ToInt32(Console.ReadLine());
if(isEven(num)==0)
Console.WriteLine($"{num} is EVEN");
else
Console.WriteLine($"{num} is ODD");
}
static int isEven(int n)
{
return n&1;
}
}
}
11. By INFINITΓπ
Made by INFINITΓπ. ( Source )
2 Even Number
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
var userNumber = Convert.ToInt32(Console.ReadLine());
var check = userNumber % 2;
if (check == 0)
{
Console.WriteLine("Even Number");
}
else
{
Console.WriteLine("Odd Number");
}
}
}
}
12. By Faisal
Made by Faisal. ( Source )
Input your number: 4 even
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
Console.Write("Input your number: ");
int number = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(number);
Console.WriteLine((number % 2 == 0) ? "even" : "odd");
}
}
}
13. By ipaz12
Made by ipaz12. Prints all the odd and even numbers to 100. ( Source )
1 is Odd 2 is Even 3 is Odd 4 is Even 5 is Odd 6 is Even 7 is Odd 8 is Even 9 is Odd 10 is Even 11 is Odd 12 is Even 13 is Odd 14 is Even 15 is Odd 16 is Even 17 is Odd 18 is Even 19 is Odd 20 is Even 21 is Odd 22 is Even 23 is Odd 24 is Even 25 is Odd 26 is Even 27 is Odd 28 is Even 29 is Odd 30 is Even 31 is Odd 32 is Even 33 is Odd 34 is Even 35 is Odd 36 is Even 37 is Odd 38 is Even 39 is Odd 40 is Even 41 is Odd 42 is Even 43 is Odd 44 is Even 45 is Odd 46 is Even 47 is Odd 48 is Even 49 is Odd 50 is Even 51 is Odd 52 is Even 53 is Odd 54 is Even 55 is Odd 56 is Even 57 is Odd 58 is Even 59 is Odd 60 is Even 61 is Odd 62 is Even 63 is Odd 64 is Even 65 is Odd 66 is Even 67 is Odd 68 is Even 69 is Odd 70 is Even 71 is Odd 72 is Even 73 is Odd 74 is Even 75 is Odd 76 is Even 77 is Odd 78 is Even 79 is Odd 80 is Even 81 is Odd 82 is Even 83 is Odd 84 is Even 85 is Odd 86 is Even 87 is Odd 88 is Even 89 is Odd 90 is Even 91 is Odd 92 is Even 93 is Odd 94 is Even 95 is Odd 96 is Even 97 is Odd 98 is Even 99 is Odd 100 is Even
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
for (int i = 1; i <=100 ; i++){
if (i%2 == 0){
Console.WriteLine($"{i} is Even");
}
else{
Console.WriteLine($"{i} is Odd");
}
}
}
}
}