Odd Even Program in C#

Advertisements

Prev Tutorial Next Tutorial

Odd Even Number Program in C#

Even number is divisible by 2 but Odd number is not divisible by 2. Here we apply this concept to write even odd program in C#. To display any message on screen we use WriteLine() the static method of Console class.

Check Number is Odd or Even Program in C#

using System;  
public class Odd_Even  
{  
public static void Main()  
{
int num1, rem1;
Console.Write("Enter any Number: ");
num1= Convert.ToInt32(Console.ReadLine()); 
rem1 = num1 % 2;
if (rem1 == 0)
{
Console.WriteLine("{0} is an even number.\n",num1);
}
else
{
Console.WriteLine("{0} is an odd number.\n",num1);
}
}
}

Output

Enter any Number: 10
10 is an even number

Code Explanation

  • Every Main method must be contained inside a class (Hello1 in this case).
  • The System.Console class contains a WriteLine method that can be used to display a string to the console.

Prev Tutorial Next Tutorial

Advertisements

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Pure VPN Privide Lowest Price VPN Just @ $1.65. Per Month with Non Detected IP Lowest Price Non Detected IP VPN

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

Download Projects

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements