f() and g(). In C and C++, the + operator is not a sequence point, and therefore in the expression f()+g() it is possible that either f() or g() will be executed first. The comma operator is a sequence point, and therefore in the code f(),g() the order of evaluation is defined (i.e., first f() is called, and then g() is called). The type and value of the whole expression are those of g(); the value of f() is discarded.Sequence points also come into play when the same variable is modified more than once. An often-cited example is the expression i=i++, which both assigns i to itself and increments i; what is the final value of i? Language definitions might specify one of the possible behaviors or simply say the behavior is undefined. In C and C++, evaluating such an expression yields undefined behavior.
*p++ != 0 && *q++ != 0, all side effects of the sub-expression *p++ != 0 are completed before any attempt to access q.a = (*p++) ? (*p++) : 0 there is a sequence point after the first *p++, meaning it has already been incremented by the time the second instance is executed.a=b;), return statements, the controlling expressions of if, switch, while, or do-while statements, and all three expressions in a for statement.f(i++) + g(j++) + h(k++), f is called with a parameter of the original value of i, but i is incremented before entering the body of f. Similarly, j and k are updated before entering g and h respectively. However, it is not specified in which order f(), g(), h() are executed, nor in which order i, j, k are incremented. The values of j and k in the body of f are therefore undefined. Note that a function call f(a,b,c) is not a use of the comma operator and the order of evaluation for a, b, and c is unspecified.5 in the declaration int a = 5;.