Wednesday, 2 April 2014

code for calculator



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

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void bntadd_Click(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(txtfname.Text.ToString());
            int b = Convert.ToInt32(txtsname.Text.ToString());
            int c = a + b;
            txtdisp.Text = c.ToString();


        }

        private void btnsub_Click(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(txtfname.Text.ToString());
            int b = Convert.ToInt32(txtsname.Text.ToString());
            int c = a - b;
            txtdisp.Text = c.ToString();

        }

        private void btnmul_Click(object sender, EventArgs e)
        {
            int a = Convert.ToInt32(txtfname.Text.ToString());
            int b = Convert.ToInt32(txtsname.Text.ToString());
            int c = a * b;
            txtdisp.Text = c.ToString();

        }

        private void btndiv_Click(object sender, EventArgs e)
        {
          float a = Convert.ToInt32(txtfname.Text.ToString());
          float b = Convert.ToInt32(txtsname.Text.ToString());
          float c = a / b;
            txtdisp.Text = c.ToString();

        }
    }
}

No comments:

Post a Comment