Multiplication Table in C#
Submitted by donbermoy on Tuesday, June 24, 2014 - 21:15.
Today in C#, I will teach you how to create a program that has the multiplication table functions.
So, now let's start this tutorial!
1. Let's start with creating a Windows Form Application in C# for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
2. Next, add Three TextBoxes namely TextBox1 for entering the first number, TextBox2 for entering the number limit, and TextBox3 for the result of the Multiplication Table. You must design your interface like this:
3. Next, put this code in Button1_Click so that it will display the Multiplication table.
We initialized n1, n2 as Integer because we passed the value of our input in TextBox1 to n1 and TextBox2 to n2. Our variable i will start at 1 up to the n2 as we input it in TextBox2. Next, we initialized a as Integer to have the result of multiplication done in n1 up to the value of i which limits at n2. Then, TextBox3 will now have the value of n1*i = a. We use \n to create a newline.
Output:
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
If you have some queries, feel free to contact the number or e-mail below.
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- public void Button1_Click(System.Object sender, System.EventArgs e)
- {
- int n1 = default(int);
- int n2 = default(int);
- int i = default(int);
- n1 = (int) (Conversion.Val(TextBox1.Text));
- n2 = (int) (Conversion.Val(TextBox2.Text));
- for (i = 1; i <= n2; i++)
- {
- int a = default(int);
- a = n1 * i;
- TextBox3.Text = TextBox3.Text + n1.ToString() + " * " + i.ToString() + " = " + a.ToString();
- TextBox3.Text = TextBox3.Text + "\r\n";
- }
- }
Add new comment
- 955 views