Operator precedence, with () and without ()
class MainClass
{
public static void Main()
{
int myInt = 2 + 5 * 10;
System.Console.WriteLine("2 + 5 * 10 = " + myInt);
myInt = (2 + 5) * 10;
System.Console.WriteLine("(2 + 5) * 10 = " + myInt);
myInt = 2 * 20 / 5;
System.Console.WriteLine("2 * 20 / 5 = " + myInt);
}
}
Output 2 + 5 * 10 = 52
(2 + 5) * 10 = 70
2 * 20 / 5 = 8
|
HTML code for linking to this page:
Related in same category :
-
-
|