0% found this document useful (0 votes)
29 views3 pages

Calci C#

This C# program defines a basic calculator application with a graphical user interface. It contains code to display numbers and arithmetic operators when buttons are clicked, store the first and second entered values as well as the selected operation, and display the result of the calculation by evaluating the stored values and operation when the equals button is clicked. The program uses common namespaces for graphical and forms functionality and defines a Form class to set up the calculator UI and handle button click events to update the displayed values and perform calculations.

Uploaded by

Hrisav Bhowmick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Calci C#

This C# program defines a basic calculator application with a graphical user interface. It contains code to display numbers and arithmetic operators when buttons are clicked, store the first and second entered values as well as the selected operation, and display the result of the calculation by evaluating the stored values and operation when the equals button is clicked. The program uses common namespaces for graphical and forms functionality and defines a Form class to set up the calculator UI and handle button click events to update the displayed values and perform calculations.

Uploaded by

Hrisav Bhowmick
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PROGRAM

Form.cs
using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;

namespace calci
{
public partial class Form1 : Form
{
int first, second, temp;
public Form1()
{
InitializeComponent();
}
private void clickk(object sender, EventArgs e)
{
Button b1 = (Button)sender;
if (b1.Text.Equals("button1"))
{
textBox1.Text += "1";
}
if (b1.Text.Equals("button2"))
{
textBox1.Text += "2";
}
if (b1.Text.Equals("button3"))
{
textBox1.Text += "3";
}
if (b1.Text.Equals("button4"))
{
textBox1.Text += "4";
}
if (b1.Text.Equals("button5"))
{
textBox1.Text += "5";
}
if (b1.Text.Equals("button6"))
{
textBox1.Text += "6";
}
if (b1.Text.Equals("button7"))
{
textBox1.Text += "7";
}
if (b1.Text.Equals("button8"))

UR11CS032

{
textBox1.Text += "8";
}
if (b1.Text.Equals("button9"))
{
textBox1.Text += "9";
}
}
private void op(object sender, EventArgs e)
{
Button oper = (Button)sender;
if (oper.Text.Equals("-"))
{
first = int.Parse(textBox1.Text);
temp = 1;
textBox1.Text = "";
}
if (oper.Text.Equals("+"))
{
first = int.Parse(textBox1.Text);
temp = 2;
textBox1.Text = "";
}
}
private void button10_Click(object sender, EventArgs e)
{
second = int.Parse(textBox1.Text);
if (temp == 1)
{
textBox1.Text = "" + (first - second);
}
if (temp == 2)
{
textBox1.Text = "" + (first + second);
}
}
}
}

Program.cs
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Windows.Forms;

namespace calci
{
static class Program
{

UR11CS032

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

OUTPUT

UR11CS032

You might also like