Advertisement
lIlIlIlIIlI

Introduction_simpleIfElse

Sep 9th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.     int a;
  5.     int num;
  6.    
  7.     printf("enter a number: ");
  8.     scanf("%d", &num);
  9.     num % 2 == 1 ? printf("Odd") : printf("Even");
  10.     return 0;
  11. }
  12.  
  13. /*
  14. if判別式如下:
  15. if (num % 2 == 1) printf("Odd");
  16. else printf("Even");
  17.  
  18. 可以改寫成這樣:
  19. num % 2 == 1 ? printf("Odd") : printf("Even");
  20. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement