<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3.    SET bet amount to 0
  4.    WHILE bet amount is less than 4
  5.       Display user greeting message
  6.       SCAN for chosen
  7.       Display user stake message
  8.       SCAN for stake
  9.       Display user bet value and greeting
  10.       Generate random number
  11.       IF user bet equals random number
  12.          THEN
  13.             Update balance with win amount
  14.             Display congratulations greeting message with balance update
  15.          ELSE
  16.             Subtract stake value from balance
  17.             Display loss message with balance update
  18.       END IF
  19.       Increase bet amount by 1   
  20.    END WHILE
  21. Display final balance message to user
  22. END         
  23. */
  24.  
  25.  
  26. #include <time.h>
  27. #include <stdlib.h>
  28. #include <stdio.h>
  29.  
  30. int spin_r() {
  31.     int r_num; 
  32.     r_num = 1+(rand()%38);
  33.     printf("\nThe ball has landed on %d!\n", (r_num-1));
  34.     return r_num;
  35. }
  36. int spin_rspin_r();
  37.  
  38. int main() {
  39.  
  40.    /*Defining the Variables*/
  41.     int chosen;
  42.     int stk;
  43.     int bet_amount = 0;
  44.     int balance = 0;
  45.     int r_num;
  46.    
  47.    /*Start seeding*/
  48.     srand(time(NULL));
  49.    
  50.     /*Start while loop for bet amount less than 4*/
  51.     while (bet_amount < 4) {
  52.         printf("Choose a number between 0 and 37 (37 = 00)");
  53.         scanf("%d", &chosen);
  54.         printf("- How much would you like to bet?\n");
  55.         scanf("%d", &stk);
  56.         printf("You have have %d on %d, Good Luck", stk, chosen);
  57.         r_num = (spin_r() - 1);
  58.                
  59.                /*If selected input value is chosen then congratulations greeting message is shown and balance is updated*/
  60.                if (r_num == chosen) {
  61.                     balance += (stk * 35);
  62.                     printf("Congratulations, you won. Your new balance is %d\n\n", balance); }
  63.                    
  64.                 /*Else if the input value chosen incorrectly, then give loss message is shown and balance is updated*/
  65.                 else
  66.                 {
  67.                     balance -= stk;
  68.                     printf("Sorry, you lost %d. Your new balance is %d\n\n", stk, balance);
  69.                 }   
  70.                     /*Add one to the bet amount to limit while loop*/
  71.                     bet_amount += 1;
  72.                    
  73.  
  74. /*User is met with message of final balance shown*/
  75. }
  76. printf("Your final balance is %d", balance);}