Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //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
- class SeveralOperations
- {
- static void Main()
- {
- int[] nums = new int[2];
- int sumary = 0;
- int substraction = 0;
- int multiply = 0;
- int? devision;
- int? modul;
- for (int i = 0; i < 2; i++)
- {
- Console.WriteLine("Enter number: ", i + 1);
- int number = int.Parse(Console.ReadLine());
- nums[i] = number;
- }
- sumary = nums[0] + nums[1];
- substraction = nums[0] - nums[1];
- multiply = nums[0] * nums[1];
- devision = nums[0] / nums[1];
- modul = nums[0] % nums[1];
- Console.WriteLine("{0}\n{1}\n{2}\n{3}\n{4}\n", sumary, substraction, multiply, devision, modul);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement