Operation rules of comma expression in C language

angryTom
Release: 2020-02-20 13:09:28
Original
26586 people have browsed it

Operation rules of comma expression in C language

Operation rules of comma expressions in c language

Comma expressions in c language are performed from left to right: k=3*2 =6, K 2=8, the expression returns 8.

Usage of comma expression:

When used as a sequence point, the combination order is from left to right, and is used for sequential evaluation. After completion, the value of the entire expression is The value of the last expression.

Example: (Recommended learning:c language video tutorial)

#include  int main() { int a, s, d; s = 2; d = 3; a = (s + 2, d + 4); printf("%d\n", a); return 0; }
Copy after login

Result

7
Copy after login

Notes

(1) Comma The operation process of expressions is: calculating expressions one by one from left to right.

(2) As a whole, the value of the comma expression is the value of the last expression (that is, expression n).

(3) The comma operator has the lowest precedence among all operators.

PHP Chinese website, a large number ofprogramming learning courses, welcome to learn!

The above is the detailed content of Operation rules of comma expression in C language. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!