004-inc-dec.c (496B)
1 /* tests/cc-e2e/04-inc-dec.c — pre/post increment and decrement. 2 * Split from 01-kitchen-sink. */ 3 4 int test_inc_dec(void) { 5 int x = 5; 6 int a = x++; /* a=5, x=6 */ 7 int b = ++x; /* b=7, x=7 */ 8 int c = x--; /* c=7, x=6 */ 9 int d = --x; /* d=5, x=5 */ 10 return a + b + c + d + x; /* 5+7+7+5+5 = 29 */ 11 } 12 13 int main(int argc, char **argv) { 14 if (test_inc_dec() != 29) return 1; 15 return 0; 16 }