Compute and display the sum, difference, product, quotient and square root of two numbers in Windows Form Application.
Thank you for your help.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Dipankar BiswasPosted Nov 16, 2014, 5:00 AM
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 WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int x;
int y;
int result;
private void button1_Click(object sender, EventArgs e)
{
x = Convert.ToInt32(textBox1.Text);
y = Convert.ToInt32(textBox2.Text);
result = x + y;
label1.Text = Convert.ToString(result);
}
private void button2_Click(object sender, EventArgs e)
{
x = Convert.ToInt32(textBox1.Text);
y = Convert.ToInt32(textBox2.Text);
result = x - y;
label1.Text = Convert.ToString(result);
}
private void button3_Click(object sender, EventArgs e)
{
x = Convert.ToInt32(textBox1.Text);
y = Convert.ToInt32(textBox2.Text);
result = x / y;
label1.Text = Convert.ToString(result);
}
private void button4_Click(object sender, EventArgs e)
{
x = Convert.ToInt32(textBox1.Text);
y = Convert.ToInt32(textBox2.Text);
result = x * x;
label1.Text = Convert.ToString(result);
}
private void button5_Click(object sender, EventArgs e)
{
int x = Convert.ToInt32(textBox1.Text);
double result = Math.Sqrt(x);
label1.Text = Convert.ToString(result);
}
}
}