Home Backend Development C#.Net Tutorial What is the precedence of arithmetic operators, assignment operators and relational operators?

What is the precedence of arithmetic operators, assignment operators and relational operators?

Jun 19, 2020 pm 04:06 PM
arithmetic operators assignment operator

What is the precedence of arithmetic operators, assignment operators and relational operators?

What is the precedence of arithmetic operators, assignment operators and relational operators?

The priority order is: arithmetic operators > relational operators > assignment operations.

Among arithmetic operators, the multiplication operator [*], division operator [/], and remainder operator [%] belong to the third level of priority, and the addition operator [ ] and subtraction operator The symbol [-] belongs to the fourth level.

The relational operator has 6 types of relations, namely less than, less than or equal to, greater than, equal to, greater than or equal to, and not equal to. Among them, the relational operator [< > <= >= ] belongs to the sixth level of priority, and the equal operator [==] and the not equal operator [!=] belong to the seventh level of priority.

The assignment operator [= = -= *= /= %= >>= <<= &= |= ^=] belongs to the fourteenth level of priority.

So, the priority order is: arithmetic operators are higher than relational operators and higher than assignment operations.

Extended information:

Priority related regulations:

1. Priority has nothing to do with the order of evaluation. For example, a b && b*c, although * has the highest priority, the evaluation order of this expression is from left to right. The priorities decrease from top to bottom, with the topmost operator having the highest priority and the comma operator having the lowest priority.

2. In the same priority, combine according to the associativity. The associativity of most operators is from left to right. Only three precedences are associative from right to left. They are unary operators, conditional operators, and assignment operators.

3. Pointers are optimal, and monocular operations are better than binocular operations. Such as plus and minus signs. Arithmetic operations are performed first, then shift operations, and finally bit operations. Please pay special attention to: 1 << 3 2 & 7 is equivalent to the final combination of (1 << (3 2))&7 logical operations.

Recommended tutorial: "C Language"

The above is the detailed content of What is the precedence of arithmetic operators, assignment operators and relational operators?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What does '+=' mean in python What does '+=' mean in python Jan 05, 2023 pm 05:53 PM

In Python, "+=" refers to the "addition assignment" operator, which is a type of assignment operator. Its function is to perform an addition operation first, and then assign the result to the variable on the left side of the operator; the syntax is "x += y", the equivalent form is "x = x + y". The "+=" operator can only assign values ​​to existing variables, because the variable itself needs to participate in the operation during the assignment process. If the variable is not defined in advance, its value is unknown and cannot participate in the operation.

Python Operators: The Ultimate Guide from Newbie to Master Python Operators: The Ultimate Guide from Newbie to Master Mar 11, 2024 am 09:13 AM

Introduction to python operators Operators are special symbols or keywords used to perform operations between two or more operands. Python provides a variety of operators covering a wide range of uses, from basic mathematical operations to complex data manipulation. Mathematical operators Mathematical operators are used to perform common mathematical operations. They include: operator operation examples + addition a + b - subtraction a-b * multiplication a * b / division a / b % modulo operation (take the remainder) a % b ** power operation a ** b // integer division (discard the remainder) a//b Logical Operators Logical operators are used to concatenate Boolean values ​​and evaluate conditions. They include: operator operations examples and logical and aandbor logical or aorbnot logical not nota comparison operations

The Secret Garden of Operators: Discover Hidden Treasures in Python The Secret Garden of Operators: Discover Hidden Treasures in Python Mar 11, 2024 am 09:13 AM

The Secret Garden of Operators Python operators are symbols or keywords used to perform various operations. They enable developers to express complex logic concisely and clearly and improve code efficiency. Python provides a wide range of operator types, each with its specific purpose and usage. Logical Operators Logical operators are used to combine Boolean values ​​and perform logical operations. The main ones are: and: Returns the Boolean value True, if all operands are True, otherwise it returns False. or: Returns a Boolean value True if any operand is True, otherwise returns False. not: Negate the Boolean value, change True to False, and change False to True. Demo code: x=Truey

Uncovering the Power of Python Operators: Writing Elegant and Efficient Code Uncovering the Power of Python Operators: Writing Elegant and Efficient Code Mar 11, 2024 am 09:28 AM

Python operators are a key component of the programming language, enabling developers to perform a wide range of operations, from simple arithmetic to complex bit manipulation. Mastering the syntax, semantics, and functionality of operators is essential to using Python effectively. Arithmetic Operators Arithmetic operators are used to perform basic arithmetic operations. They include addition (+), subtraction (-), multiplication (*), division (/), modulo (%), exponentiation (**), and floor division (//). The following example demonstrates the use of arithmetic operators: >>a=10>>b=5#Addition c=a+bprint(c)#Output: 15#Subtraction c=a-bprint(c)#Output: 5#Multiplication c=a*bprint(c)#output

Secrets of Python Operators: Mastering the Cornerstone of Programming Secrets of Python Operators: Mastering the Cornerstone of Programming Mar 11, 2024 am 09:19 AM

Python operators are special symbols or words used to perform specific operations on values ​​or to combine values. They are the fundamental building blocks of programming languages ​​and are key to understanding and writing efficient code. Arithmetic Operators Arithmetic operators are used to perform basic mathematical operations such as addition, subtraction, multiplication, division, and remainder. The following are the most commonly used arithmetic operators: +Addition-Subtraction*Multiplication/Division%Remainder Example: x=10y=5print(x+y)#Output: 15print(x-y)#Output: 5print(x*y)#Output :50print(x/y)#Output: 2.0print(x%y)#Output: 0 Comparison Operator The comparison operator is used to compare two values ​​and return a Boolean value (True

In C/C++, what is the meaning of operator c=a+++b? In C/C++, what is the meaning of operator c=a+++b? Sep 01, 2023 pm 04:29 PM

Let us consider that in C or C++, there is a similar statement: c=a+++b; So what is the meaning of this line of code? Okay, let a and b be 2 and 5 respectively. This expression can be viewed as two different types. c=(a++)+bc=a+(++b) has post-increment operator and pre-increment operator. How they are used depends on how they are used. There are two basic concepts. Priority and associativity. Now if we check the expression from left to right, the result will be these two. c=(a++)+b→2+5=7c=a+(++b)→2+6=8 Now let’s check which option is selected by the compiler - example code #include<io

Explain the concepts of logical operators and assignment operators in C language Explain the concepts of logical operators and assignment operators in C language Sep 13, 2023 pm 06:17 PM

First, let's learn about logical operators. Logical Operators These are used to logically combine two (or more) expressions. They are logical AND (&&), logical OR (||) and logical NOT (!) logical AND (&&) exp1exp2exp1&&exp2TTTTFFFTFFFF logical OR (||) exp1exp2exp1||exp2TTTTFTFTTFFF logical NOT (!) exp!expTTFT Operator Description Example a= 10,b=20,c=30 output&&logical AND(a>b)&&(a<c)(10>

What does php module equal mean? What does php module equal mean? Feb 02, 2023 pm 07:27 PM

PHP modular equals refers to "%=", which is an extended assignment operator, which means to perform the modulo operation first, and then assign the result to the variable on the left side of the operator; the syntax is "x %= y", the equivalent form is "x = x % y". The extended assignment operator combines = with other operators (including arithmetic operators, bitwise operators and logical operators) to expand it into a more powerful assignment operator; the expanded assignment operator will make the assignment expression Writing is more elegant and convenient.

See all articles