﻿# Operator precedence in C and C\+\+

Any language expression consists of operands \(variables, constants, etc\.\) connected with each other by operators\. Operations are executed in a strict order\. The value that determines a privilege to execute a certain operation is called precedence\. The operation execution order can be regulated by use of parentheses\.

![Priority/image1.png](https://import.viva64.com/docx/blog/Priority/image1.png)

Table 1\. Operation precedence in C/C\+\+\.



You may often see errors in programs which are caused by the fact that it is easy for programmers to forget the exact priorities of operations \([article on the topic](https://pvs-studio.com/en/blog/posts/cpp/a0072/)\)\. This is why professional developers do not feel embarrassed about using additional parentheses: this method secures them from accidental mistakes, and makes expressions more readable\.

**Note\.** The PVS\-Studio analyzer provides several diagnostics such as [V648](https://pvs-studio.com/en/docs/warnings/v648/)\. These diagnostics help detect errors related to operator precedence\. [Try](https://pvs-studio.com/en/pvs-studio/try-free/) to check your code\.

## References

1. Wikipedia\. [Operators in C and C\+\+](https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B)\.
1. Cppreference\. [C\+\+ Operator Precedence](https://en.cppreference.com/w/cpp/language/operator_precedence)\.