Create a simple program to check whether the no is even or odd in c#.
Create a simple program to check whether the no is even or odd:
output:
code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace lab_5_paractise_if_else_switch_case_
{
class Program
{
static void Main(string[] args)
{
int num = 0, even = 0, odd = 0;
for (int cnt = 0; cnt <= 5; cnt++)
{
Console.WriteLine("Enter Number:");
num = Convert.ToInt32(Console.ReadLine());
if (num % 2 == 0)
{
Console.WriteLine("Number is even:{0}", num);
even++;
}
else
{
Console.WriteLine("Number is odd:{0}", num);
odd++;
}
Console.WriteLine("Even Number:{0}", even);
Console.WriteLine("Number is odd:{0}", odd);
}
}
}
}
Comments
Post a Comment