Advertisement
DrAungWinHtut

switch.c

May 10th, 2023
849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int ans=0;
  5.  
  6.     do{
  7.         printf("1-play game\n");
  8.         printf("2-save game\n");
  9.         printf("3-exit game\n");
  10.         printf("please choose 1,2,3: ");
  11.         scanf("%d",&ans);
  12.  
  13.         switch(ans){
  14.             case 1: printf("playing game!...\n\n"); break;
  15.             case 2: printf("saving game!...\n\n");break;
  16.             case 3: return 0;
  17.             default: printf("wrong input, please enter 1, 2, 3 only!!!\n\n\n"); break;
  18.         }
  19.  
  20.     }while(1);    
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement