boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

006-ternary.c (363B)


      1 /* tests/cc-e2e/06-ternary.c — `?:` ternary operator.
      2  * Split from 01-kitchen-sink. */
      3 
      4 int test_ternary(void) {
      5     int x = 5;
      6     int y = (x > 3) ? 10  : 20;     /* 10  */
      7     int z = (x < 3) ? 100 : 200;    /* 200 */
      8     return y + z;                   /* 210 */
      9 }
     10 
     11 int main(int argc, char **argv) {
     12     if (test_ternary() != 210) return 1;
     13     return 0;
     14 }