- You'll create a program to add 1 plus 2 times 3.
- Do addition first or multiplication first.
- In basic math rules, multiplication and division have higher priority than addition or subtraction.
- It is the same in programming as in mathematics.
- To add 1 to 2 and then multiply by 3, use parentheses around the 1 and 2.
Use Console.WriteLine(); to output result
class Program/*from w w w . j a v a 2 s . c o m*/
static void Main(string args)
// Multiplication has greater priority
Console.WriteLine(1 + 2 * 3);
// Forcing priority using parentheses
Console.WriteLine((1 + 2) * 3);