Advertisement
math230

Ternary operator example

Sep 5th, 2019
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.26 KB | None | 0 0
  1. //Ternary operator example
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. int main(){
  6.   int x = 3, y = 8;
  7.   int min = (x < 7) ? x : y; //"returns" a value
  8.  
  9.   printf("conditional op result: %d \n", min);
  10.   return 0;
  11. }
  12.  
  13. /*
  14. if (x < y)
  15.   min = x;
  16. else
  17.   min = y;
  18. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement