Multiplication Table in C#

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: design 3. Next, put this code in Button1_Click so that it will display the Multiplication table.
  1. public void Button1_Click(System.Object sender, System.EventArgs e)
  2. {
  3. int n1 = default(int);
  4. int n2 = default(int);
  5. int i = default(int);
  6. n1 = (int) (Conversion.Val(TextBox1.Text));
  7. n2 = (int) (Conversion.Val(TextBox2.Text));
  8.  
  9. for (i = 1; i <= n2; i++)
  10. {
  11. int a = default(int);
  12. a = n1 * i;
  13. TextBox3.Text = TextBox3.Text + n1.ToString() + " * " + i.ToString() + " = " + a.ToString();
  14. TextBox3.Text = TextBox3.Text + "\r\n";
  15. }
  16.  
  17. }
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: 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

Add new comment