Tuesday, 27 November 2012

Even Numbber Generation

using System;
using System.Collections.Generic;
using System.Text;

namespace even_number_generation
{
class Program
{
static void Main(string[] args)
{
int n, m,l,i;
Console.WriteLine("EVEN NUMBER GENERATION");
Console.WriteLine("**********************");
Console.WriteLine("Enter The Starting Range");
n = int.Parse(Console.ReadLine());
Console.WriteLine("Enter The Finishing Range");
m = int.Parse(Console.ReadLine());
Console.WriteLine("The Answer is");
l = n % 2;
if (l == 0)
{
for (i = n; i <= m; i=i + 2)
{
Console.WriteLine("{0}", i);
}
}
else
{
for (i = n + 1; i <= m; i=i + 2)
{
Console.WriteLine("{0}", i);
}
}


}
}
}

No comments:

Post a Comment