ODD or EVEN check in C#
ODD or EVEN check in C#
using System; public class Program { public static void Main() { Console.WriteLine("ODD or EVEN check in C#\n"); string input; int j = 0; int iConvert; Console.WriteLine(" Enter the number: "); input = Console.ReadLine(); iConvert = Convert.ToInt32(input); if (iConvert == 0) { Console.WriteLine("The given number is neither odd nor even "); } else { j = (iConvert % 2); if (j == 0) { Console.WriteLine("The given number is even "); } else { Console.WriteLine("The given number is odd "); } } } }DEMO
ODD or EVEN check in C#
Reviewed by Bhaumik Patel
on
8:13 AM
Rating: