To display odd and even numbers in a limit


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();
}
}
}

Click Here…to Download the PDF file with Design, Input and Output desin & Source Code file

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s