using System;
namespace OperatorPrecedence
{
class Program
{
static void Main(string[] args)
{
int a = 5;
int b = 7;
int c = 10;
int d = 12;
int e;
Console.WriteLine(" Operator precedence");
Console.WriteLine("= += -= *= /= %= &= ^= <<= >>=");
e = (a + b) * c / d; // (5 +7)*10/12 = 10
Console.WriteLine("Value of (a + b) * c / d is : {0}", e);
e = ((a + b) * c) / d; //(( 5+7 )*10) / 12 =10
Console.WriteLine("Value of ((a + b) * c) / d is : {0}", e);
e = a + (b * c) / d; // 5 + (7*10)/12 = 10{0}", e);
Console.WriteLine("Value of a + (b * c) / d is : {0}", e);
Console.ReadLine();
}
}
}
|