Guest User

Untitled

a guest
Jun 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int roullette()
  6. {
  7. srandom(time(NULL));
  8. int bullet = random() % 13;
  9. int spin = random() % 13;
  10.  
  11. if ( bullet == spin )
  12. {
  13. return 1;
  14. } else {
  15. return 0;
  16. }
  17. }
  18.  
  19. int menu()
  20. {
  21.  
  22. char answer;
  23.  
  24. printf("Do you want to try your luck again?\n");
  25. scanf("%s", &answer);
  26. printf("Your answer was: %c\n", answer);
  27. switch(answer)
  28. {
  29. case 'y':
  30. return 1;
  31. break;
  32.  
  33. case 'n':
  34. printf("Chicken!\n");
  35. break;
  36.  
  37. default:
  38. printf("Erroneous choice: %s", answer);
  39. return 2;
  40. }
  41. }
  42.  
  43. int main()
  44. {
  45. printf("Spinning...\n");
  46. sleep(1);
  47.  
  48. if ( roullette() == 1)
  49. {
  50. printf("BAM, you're dead!\n");
  51. } else {
  52. printf("You survived!\n");
  53. }
  54.  
  55. if ( menu() == 1) menu();
  56. return 0;
  57. }
Add Comment
Please, Sign In to add comment