Search This Blog

Monday, 22 August 2011

Maths Table

Let us create a simple math table.


Let us take a textbox where we enter the number to be calculated and then we will take a button, clicking on the button will display output in the List Box..

And the code follows :

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        int i;

        for (i = 1; i <= 10; i++)
        {
            int j = int.Parse(TextBox1.Text);
            int[] k = new int[11];
            k[i] = i * j;

            ListBox1.Items.Add(i.ToString() + " * " + j.ToString() + " = " + k[i].ToString());
        }

    }

}

And the output as shown below :

Here I taking for 5 multiples



No comments:

Post a Comment