Press "Enter" to skip to content

Find Square and Square Root of a Number in C#

It is a simple C# program to find Square and Square root of any number.
Here first text box will accept number to find square and square root. After typing a number, to find square of given number, click on ‘Square’ button, then you will get square in second text box. Click on ‘Square root’ button to get square root of given number.

Interface with Example Input – Output: 

Code behind interface: 

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 squar_and_squar_root
    public partial class Form1 : Form
        double num;
        public Form1()
        private void Square_button_Click(object sender, EventArgs e)
            num = Convert.ToDouble(number_box.Text);
            result_text_box.Text = (num * num).ToString();

        private void Square_root_button_Click(object sender, EventArgs e) 
            num = Convert.ToDouble(number_box.Text);
            result_text_box.Text = (Math.Sqrt(num)).ToString();

More C# Programs

One Comment

  1. zortilo nrel zortilo nrel 19th April 2021

    I think this website has some real wonderful information for everyone :D. “Heat cannot be separated from fire, or beauty from The Eternal.” by Alighieri Dante.

Leave a Reply