Advertisement
thenewboston

C Programming Tutorial - 23 - Shorthand if else

Aug 22nd, 2014
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main()
  5. {
  6.     //choosing teams
  7.     char lastName[20];
  8.     printf("Enter your last name:\n");
  9.     scanf("%s", lastName);
  10.  
  11.     //test the first letter
  12.     (lastName[0] < 'M') ? printf("Blue team") : printf("Red team");
  13.  
  14.     return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement