Click here to Skip to main content
Click here to Skip to main content

Software Table

, 14 Mar 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
This software allows you show table (multiplication) of any digit.

Introduction

In this tip, I show you how to multiply digits and show it as a table. This is helpful for kids to learn multiplication tables.

Background

The basic idea of this software is understanding the "for loop" function for beginners. The for loop is a bit different. It's preferred when you know how many iterations you want, either because you know the exact amount of iterations, or because you have a variable containing the amount. The for loop in C# is useful for iterating over arrays and for sequential processing. The statements within the code block of a for loop will execute a series of statements as long as a specific condition remains true.

Using the Code

It is very simple to understand how to use for loops in your program.

Here is the 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 looooops_table
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private string gettable(int a,int b,int c)
        {
            string str;
            str = "";
            for (int i = b; i <= c; i++)
            {
                str = str + a.ToString() + " X" + i.ToString() + "=" + (a * i) + "\n";
            }

            return str;            
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void btn1_Click(object sender, EventArgs e)
        {
            lbl1.Text = gettable(int.Parse(txt1.Text), int.Parse(txt2.Text), 
				int.Parse(txt3.Text)).ToString();
        }

        private void btnexit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnclear_Click(object sender, EventArgs e)
        {
            txt1.Text = "";
            txt2.Text = "";
            txt3.Text = "";
            lbl1.Text = "";
        }        
    }
}

...

Points of Interest

So it's time to multiply with any digit. Have fun with the software table.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Shubham Choudhary
Software Developer
India India
Hi!!! I am Shubham Choudhary
I consider myself an enthusiastic programmer, but I simply don't have time to code in my spare time. I have a life besides coding, also! And when I code in my free time, I am mostly hired for it as well. But I do read lots of articles and books in my free time.
Follow on   Twitter   LinkedIn

Comments and Discussions

 
GeneralMy vote of 2 Pinmemberjohannesnestler28-Mar-13 5:25 
GeneralRe: My vote of 2 PinmemberShubham Choudhary28-Mar-13 22:33 
SuggestionUse StringBuilders and AppendFormat to build up your data PinmemberJohn Brett15-Mar-13 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141220.1 | Last Updated 14 Mar 2013
Article Copyright 2013 by Shubham Choudhary
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid