Escolar Documentos
Profissional Documentos
Cultura Documentos
Practical No:1 Practical Title:Write a program in c# to demonstrate the functions of calculator. Description: Calculator having functionality of addition, subtraction, multiplication, division, backspace, clear, clearall,squareroot,powerof. Controls Used: 1st control Textbox 2nd control Button
namespace calcApp { public partial class Calculator : Form { double a = 0, b = 0; string op = ""; public Calculator() { InitializeComponent(); } private void btn1_Click(object sender, EventArgs e) { txtdisp.Text = txtdisp.Text + btn1.Text; } private void btn2_Click(object sender, EventArgs e) { txtdisp.Text = txtdisp.Text + btn2.Text; } private void btn3_Click(object sender, EventArgs e) { txtdisp.Text = txtdisp.Text + btn3.Text; } private void btn4_Click(object sender, EventArgs e) { txtdisp.Text = txtdisp.Text + btn4.Text; } private void btn5_Click(object sender, EventArgs e)
private void btnraise_Click(object sender, EventArgs e) { if (txtdisp.Text == "") { MessageBox.Show("please enter some data first"); } else { a = Convert.ToDouble(txtdisp.Text); txtdisp.Text = ""; op = "pow"; } } private void btnbksp_Click(object sender, EventArgs e) { if (txtdisp.Text == "") { MessageBox.Show("please enter some data first"); } else { int loc = txtdisp.Text.Length; txtdisp.Text = txtdisp.Text.Remove(loc - 1, 1); } } } }