Here i am explaining simple c# program to check even or odd no.
using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
EvenOrOdd
{
class
Program
{
static void Main(string[] args)
{
Console.WriteLine("Check
the Enter No is even or odd");
Console.Write("Enter
the no:");
int n = Convert.ToInt32(Console.ReadLine());
if(n<0)
{
Console.Write("You
have enter negative no. Sorry...");
}
else if (n % 2 == 0)
{
Console.Write("Entered
no is even.");
}
else
{
Console.Write("Entered
no is odd.");
}
Console.ReadKey();
}
}
}
debug the code and run.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.