- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the operator precedence in C#?
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
Operator precedence determines the grouping of terms in an expression. This affects evaluation of an expression. Certain operators have higher precedence than others do; for example, the multiplication operator has higher precedence than the addition operator.
The following is an example showing operator precedence −
Example
using System; namespace OperatorsAppl { class Program { static void Main(string[] args) { int a = 20; int b = 10; int c = 15; int d = 5; int e; e = (a + b) * c / d; // ( 30 * 15 ) / 5 Console.WriteLine("Value of (a + b) * c / d is : {0}", e); e = ((a + b) * c) / d; // (30 * 15 ) / 5 Console.WriteLine("Value of ((a + b) * c) / d is : {0}", e); e = (a + b) * (c / d); // (30) * (15/5) {0}", e); e = a + (b * c) / d; // 20 + (150/5) {0}", e); Console.ReadLine(); } } }
Output
Value of (a + b) * c / d is : 90 Value of ((a + b) * c) / d is : 90
- Related Articles
- What is C Operator Precedence and Associativity?
- What is Operator Precedence Parsing?
- Operator Precedence and Associativity in C
- According to Java Operator precedence, which operator has the highest precedence?
- What is Operator Precedence Parsing Algorithm in compiler design?
- What are Precedence Relations in Operator Grammar?
- PHP Operator Precedence
- Can we change operator precedence in Python?
- Explain Operator grammar and precedence parser in TOC
- What are LEADING and TRAILING operation of an operator precedence grammar?
- What is Evaluation, Precedence and Association in C language?
- Evaluating a mathematical expression considering Operator Precedence in JavaScript
- How Can MySQL operator precedence affect result set?
- What is the ?-->? operator in C++?
- How does the precedence of || operator depend on PIPES_AS_CONCAT SQL mode?

Advertisements