C# Program to Find a Year Leap or not & Find odd or Even Number
namespace Leapyearornot
{
class Leapyear
{
static void Main(string[] args)
{
Console.WriteLine("Enter Year:");
int year =
Convert.ToInt32(Console.ReadLine());
if ((year % 4 == 0) &&
(year % 100 != 0 || year % 400 == 0))
{
Console.WriteLine(year + "is a
leap year");
}
else
{
Console.WriteLine(year + "is
not a leap year");
}
}
}
OUTPUT:
using System;
namespace oddoreven
{
class oddeven
{
static void Main(string[] args)
{
Console.WriteLine("Enter Number:");
int num =
Convert.ToInt32(Console.ReadLine());
if ((num % 2 == 0))
{
Console.WriteLine(num + "is a
even number");
}
else
{
Console.WriteLine(num + "is
not a even number");
}
}
}
}
OUTPUT:
Comments
Post a Comment