# C# program to print Even and Odd numbers from 1 to 30

Learn: How to check whether a given number is EVEN or ODD? Here, we are implementing a program in C# .Net, which will check numbers from 1 to 30.

To understand the program of even numbers, first we should understand the concept of even and odd numbers.

Even numbers are those numbers they are divisible by 2. And odd numbers are those numbers they are not divisible by 2. 0 is an even number.

For example:

• 1 is an odd number.
• 2 is an even number.
• 3 is an odd number.
• 4 is an even number.

Consider the program:

```using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{

class Program
{
static void Main(string[] args)
{
int i     = 0;

Console.WriteLine("Even Numbers :");
for (i = 1; i <= 30; i++)
{
if( i%2 == 0 )
{
Console.Write(i + " ");
}
}

Console.WriteLine("\nOdd Numbers :");
for (i = 1; i <= 30; i++)
{
if (i % 2 != 0)
{
Console.Write(i + " ");
}
}

Console.WriteLine();
}
}
}
```

Output

```Even Numbers :
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30
Odd Numbers :
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29
```

What's New (MCQs)

Top Interview Coding Problems/Challenges!

IncludeHelp's Blogs

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates