1.07: Several Operation
OBJECTIVE
Write a C# program to print on screen the result of adding, subtracting, multiplying and dividing two numbers typed by the user. The remainder of the division must be displayed, too.
It might look like this:
Enter a number: 12
Enter another number: 3
12 + 3 = 15
12 - 3 = 9
12 x 3 = 36
12 / 3 = 4
12 mod 3 = 0
It might look like this:
Enter a number: 12
Enter another number: 3
12 + 3 = 15
12 - 3 = 9
12 x 3 = 36
12 / 3 = 4
12 mod 3 = 0
RESOLUTION
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace My3Development { public class SeveralOperation { public static void Main(String[] args) { int number1; int number2; Console.Write("Enter a number\t: "); number1 = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter another number\t: "); number2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("{0} + {1} = {2}", number1, number2, number1+number2); Console.WriteLine("{0} - {1} = {2}", number1, number2, number1-number2); Console.WriteLine("{0} x {1} = {2}", number1, number2, number1*number2); Console.WriteLine("{0} / {1} = {2}", number1, number2, number1/number2); Console.WriteLine("{0} mod {1} = {2}", number1, number2, number1%number2); Console.ReadKey(); } } }
0 comments :
Please Enter best of your Comments