TO DISPLAY ODD AND EVEN NUMBERS IN A LIMIT

DESIGN

Capture

SOURCE CODE

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class frmoddeven : Form
{
public frmoddeven()
{
InitializeComponent();
}
private void button3_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void btnshow_Click(object sender, EventArgs e)
{
int a = Convert.ToInt32(txtlimit.Text);
for (int i = 1; i <= a; i++)
{
if (i % 2 == 0)
lbeven.Items.Add(i.ToString());
if (i % 2 == 1)
lbodd.Items.Add(i.ToString());
}
}
private void btnclear_Click(object sender, EventArgs e)
{
txtlimit.Text = “”;
lbodd.Items.Clear();
lbeven.Items.Clear();
txtlimit.Focus();
}
}
}

Input:

Capture

 

 

Output:

 

Capture

Please click here to download the file…