Table Of Squares



TableOfSquares

This C# program demonstrates how you can use loops to display a series of numbers. For example the square roots of the numbers 1 - 20.

Here's the code!

                            using System;
                            using System.Windows.Forms;

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

                                    private void button1_Click(object sender, EventArgs e)
                                    {
                                        for (int num = 1; num <= 20; num++)
                                        {
                                            int squareRoot = num * num;
                                            lblNumber.Text += String.Format("{0}\n", num);
                                            lblRoot.Text += String.Format("{0}\n", squareRoot);
                                        }
                                    }
                                }
                            }