Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

__Page: 1__

The Islamia
University BAHAWALPUR

Submitted to
Mr. Hamza Rafique
ALPUR
By
Iqra perveen
FA19M2MA008
MCS 3rd
2019-2021.Morning
Visual Programming Assignment 2.

Create Basic Calculator Using C# Console application That is capable of


performing addition, subtraction, multiplication as well as division. User will
__Page: 2__

enter values and operation and program will calculate Result according to the
given operation

Solution
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace HelloWorld

class Program

static void Main(string[] args)

Console.WriteLine(" _________Assignment 2_______");

int x=20;

int y=10;

int s=0;

Console.WriteLine("Enter operator:");

string op = Console.ReadLine();

Console.WriteLine("operator is: " + op);

//char op='+';

switch (op)
__Page: 3__

case '+':

s=x+y;

Console.WriteLine("addition's result is= " +s );

break;

case '-':

s=x-y;

Console.WriteLine("subtraction's result is= " +s);

break;

case '*':

s=x*y;

Console.WriteLine("multiplication's result is= " +s);

break;

case '/':

s=x/y;

Console.WriteLine("division's result is= " +s);

break;

default:

Console.WriteLine("wrong operator");

break;

Console.ReadLine();

}
__Page: 4__

You might also like