using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ReadingIntegerValues
{
class Program
{
static void Main(string[] args)
{
//Read 2 integer values from user
//The Console.ReadLine() formats the input into string.
//Therefore you need to convert the string to an integer
//Use. Convert.ToInt32() to convert string to integer
int x, y, sum, diff, mul, quotient;
Console.Write("Enter first integer value: ");
x = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter second integer value: ");
y = Convert.ToInt32(Console.ReadLine());
//Process by: adding, multiplying,
//Substracting and dividing
sum = x + y;
diff = x - y;
mul = x * y;
quotient = x / y;
//display all results
Console.WriteLine("X = {0}", x);
Console.WriteLine("Y = {0}", y);
Console.WriteLine("Sum = {0} Subtraction = {1} Multiplication = {2} Division = {3}", sum, diff, mul, quotient);
Console.ReadLine();
}
}
}
No comments:
Post a Comment