using System;
class abc
{
int num;
bool a;
public void evod()
{
Console.WriteLine("Enter the number to check it is even or odd");
num=int.Parse(Console.ReadLine());
switch(a=(num%2==0))
{
case true:
Console.WriteLine("Entered by user is an even number " + num);
break;
case false:
Console.WriteLine("Entered by user is an odd number " + num);
break;
}
Console.ReadKey();
}
}
class evnods
{
public static void Main(string []args)
{
abc a=new abc();
a.evod();
}
}
Output:
class abc
{
int num;
bool a;
public void evod()
{
Console.WriteLine("Enter the number to check it is even or odd");
num=int.Parse(Console.ReadLine());
switch(a=(num%2==0))
{
case true:
Console.WriteLine("Entered by user is an even number " + num);
break;
case false:
Console.WriteLine("Entered by user is an odd number " + num);
break;
}
Console.ReadKey();
}
}
class evnods
{
public static void Main(string []args)
{
abc a=new abc();
a.evod();
}
}
Output:
No comments :
Post a Comment