Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication7
- {
- class Program
- {
- static void Main(string[] args)
- {
- int x=-1;
- Console.Write("\nInput Value : ");
- int a = int.Parse(Console.ReadLine());
- do{
- Console.Write("Input Opertor : ");
- string op = Console.ReadLine();
- calculate(op, ref a,ref x);
- } while (x != 0);
- Console.Write("End Value is {0}",a);
- Console.ReadLine();
- }
- static int calculate(string op, ref int a,ref int x)
- {
- int b;
- switch (op)
- {
- case "*": Console.Write("Input Number : ");
- b = int.Parse(Console.ReadLine());
- a = a * b;
- Console.WriteLine("Present Value = {0} ", a);
- break;
- case "/": Console.Write("Input Number : ");
- b = int.Parse(Console.ReadLine());
- a = a / b;
- Console.WriteLine("Present Value = {0} ", a);
- break;
- case "-": Console.Write("Input Number : ");
- b = int.Parse(Console.ReadLine());
- a = a - b;
- Console.WriteLine("Present Value = {0} ", a);
- break;
- case "+": Console.Write("Input Number : ");
- b = int.Parse(Console.ReadLine());
- a = a + b;
- Console.WriteLine("Present Value = {0} ", a);
- break;
- default: x = 0; break;
- }
- return a;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement