Download presentation
Presentation is loading. Please wait.
1
More C expressions ANSI-C
2
Increment and decrement operators
Expression Expression Value Effect i++ value of i before increment i is incremented ++i value of i after increment i is incremented Examples: int i = 0; int j; j = i++; /* j is 2 and i is 3 */ j = ++i; /* j is 4 and i is 4 */
3
Assigment Expression Assignment is an expression, thus it can appear anywhere an expression can appear. The value of an assigment expression is the same as the value of its right hand side. if ( x = (y + 10)) statement;
4
Conditional expression
Syntax: expr1 ? exp2 : exp3 This is equivalent to write: if (expr1) exp2; else expr3; Example: y = (x>0) ? x = -x;
5
(and <<= >>= &= ^= |=, not covered) In general a op= b;
Assignment Operators += -= *= %= (and <<= >>= &= ^= |=, not covered) In general a op= b; It’s (almost) equivalent to: a = a op (b); Example: int x = 5; int y = 10; x -= y + 3; x = x – (y + 3);
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.