adityavarma999
New member
- Joined
- Mar 29, 2012
- Messages
- 3
- Programming Experience
- Beginner
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Console1 { class Arithmetic { static void Main(string[] args) { int num1,num2,choice; int add,mul,sub; float div; while (true) { Console.WriteLine("Enter the Operation you want to perform"); Console.WriteLine("1. Addition"); Console.WriteLine("2. Subtraction"); Console.WriteLine("3. Multiplication"); Console.WriteLine("4. Division"); Console.WriteLine("5. Exit the Loop"); choice= Convert.ToInt32( Console.ReadLine()); switch(choice) { case 1: Console.WriteLine("Enter Value of Number1"); num1 = Convert.ToInt32( Console.ReadLine()); Console.WriteLine("Enter Value of Number2"); num2 = Convert.ToInt32( Console.ReadLine()); add = num1 + num2; Console.WriteLine("Addition Result of {0} and {1} is {2} ",num1,num2,add); break; case 2: Console.WriteLine("Enter Value of Number1"); num1 = Convert.ToInt32( Console.ReadLine()); Console.WriteLine("Enter Value of Number2"); num2 = Convert.ToInt32( Console.ReadLine()); sub = num1 - num2; Console.WriteLine("Subtraction Result of {0} and {1} is {2} ", num1, num2, sub); break; case 3: Console.WriteLine("Enter Value of Number1"); num1 = Convert.ToInt32( Console.ReadLine()); Console.WriteLine("Enter Value of Number2"); num2 = Convert.ToInt32( Console.ReadLine()); mul = num1 * num2; Console.WriteLine("Multiplication Result of {0} and {1} is {2} ", num1, num2, mul); break; case 4: Console.WriteLine("Enter Value of Number1"); num1 = Convert.ToInt32( Console.ReadLine()); Console.WriteLine("Enter Value of Number2"); num2 = Convert.ToInt32( Console.ReadLine()); div = (float)num1 / num2; Console.WriteLine("Division Result of {0} and {1} is {2} ", num1, num2, div); break; } } } } }
Last edited by a moderator: