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 <stdio.h> int main() { int a, s, d; s = 2; d = 3; a = (s + 2, d + 4); printf("%d\n", a); return 0; }
Result
7
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 of programming 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!