Arithmetic operators c#



In the case of integral types, those operators (except the ++ and -- operators) are defined for the int, uint, long, and ulong types. When operands are of other integral types (sbyte, byte, short, ushort, or char), their values are converted to the int type, which is also the result type of an operation. When operands are of different integral or floating-point types, their values are converted to the closest containing type, if such a type exists. For more information,

using System;

namespace CSharpFundamentals
{
    class ArithmeticalOperators
    {
        private static void Main(string[] args)
        {
			double value1, value2;
			Console.Write("Enter First Value: ");
			value1 = Convert.ToDouble(Console.ReadLine());
			
			Console.Write("Enter Second Value: ");
			value2 = Convert.ToDouble(Console.ReadLine());
			
			Console.WriteLine();
			
			Console.WriteLine("Addition: {0} + {1} = {2}", value1, value2, value1+value2);
			Console.WriteLine("Subtraction: {0} - {1} = {2}", value1, value2, value1-value2);
			Console.WriteLine("Multiplication: {0} * {1} = {2}", value1, value2, value1*value2);
			Console.WriteLine("Division: {0} / {1} = {2}", value1, value2, value1/value2);
			Console.WriteLine("Reminder: {0} % {1} = {2}", value1, value2, value1%value2);
        }
    }
}

0 Comment's

Comment Form

Submit Comment