Showing posts with label odd and even number in c#. Show all posts
Showing posts with label odd and even number in c#. Show all posts

Sunday, March 20, 2016

Odd and Even Number Checker in C#

In this sample program I wrote using Microsoft C# it will ask the user to give a number and then our program will check and determine whether the given number is odd or even.

If you have some questions please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.




Sample Program Output

Program Listing

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            System.Windows.Forms.ToolTip ToolTip1 = new System.Windows.Forms.ToolTip();
            ToolTip1.SetToolTip(this.button1, "Click here to find out if number is ODD or EVEN number.");
            ToolTip1.SetToolTip(this.button2, "Click here to clear textbox.");
            label3.Visible = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int values = Convert.ToInt32(textBox1.Text);


           if (values % 2 == 0)
            {

                label3.Visible = true;
                label3.Text ="The number " + " " + values.ToString() + " is an EVEN number.";
            }
            else
            {
                label3.Visible = true;
                label3.Text = "The number " + " " + values.ToString() + " is an ODD number.";
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            label3.Text = "";
            textBox1.Text = "";
            textBox1.Focus();
        }
    }
}