<mosaic.cnfolio.com>
PROGRAM
  1. // Read the bet number
  2. // Read the bet amount
  3. // Randomly generate the winning number
  4. // if(bet number == winning number){
  5. //  amount earned in this round is = 5 * bet amount;
  6. // }
  7. // else{
  8. //  amount earned in this round is = 0;
  9. // }
  10. // Add the amount earned in this round into the total
  11.  
  12. // Repeat above process 4 times
  13.  
  14.  
  15.  
  16. #include <stdio.h>
  17. #include <stdlib.h>
  18. #include <time.h>
  19.  
  20. int main(void) {
  21.    // your code goes here
  22.    int bet1,bet2,bet3,bet4;//variables for bet number
  23.    int amount1,amount2,amount3,amount4;//variables for bet amount
  24.    int winningnumber;//variable for winning number
  25.    int total = 0;//variable for total amount eanred
  26.    int roundamount = 0;//variable for amount earned during one round
  27.    int totalmoneyspent = 0;//variable for total money betted in all rounds
  28.    time_t t;
  29.    srand((unsigned) time(&t));//seeding
  30.    
  31.    scanf("%d",&bet1);//inputting the bet number
  32.    scanf("%d",&amount1);//inputting the bet amount
  33.    totalmoneyspent = totalmoneyspent + amount1;//calculating the totalmaountspent
  34.    winningnumber = rand() % 38;//randomly assigning the winningnumber
  35.  
  36.    //Calculating the total amount earned in this round
  37.    //Printing the values of bet number , bet amount , earning of this round
  38.    if(winningnumber == bet1){
  39.       roundamount = 5 * amount1;
  40.       total = total + roundamount;
  41.       printf("Round 1 number = %d\n",bet1);
  42.       printf("Round 1 bet amount = %d\n",amount1);
  43.       printf("Round 1 earnings = %d\n",roundamount);
  44.    }
  45.    else{
  46.       printf("Round 1 number = %d\n",bet1);
  47.       printf("Round 1 bet amount = %d\n",amount1);
  48.       printf("Round 1 earnings = 0\n");
  49.    }
  50.    printf("\n");
  51.    
  52.    scanf("%d",&bet2);//inputting the bet number
  53.    scanf("%d",&amount2);//inputting the bet amount
  54.    totalmoneyspent = totalmoneyspent + amount2;//calculating the totalmaountspent
  55.    winningnumber = rand() % 38;//randomly assigning the winningnumber
  56.  
  57.    //Calculating the total amount earned in this round
  58.    //Printing the values of bet number , bet amount , earning of this round
  59.    if(winningnumber == bet2){
  60.       roundamount = 5 * amount2;
  61.       total = total + roundamount;
  62.       printf("Round 2 number = %d\n",bet2);
  63.       printf("Round 2 bet amount = %d\n",amount2);
  64.       printf("Round 2 earnings = %d\n",roundamount);
  65.    }
  66.    else{
  67.       printf("Round 2 number = %d\n",bet2);
  68.       printf("Round 2 bet amount = %d\n",amount2);
  69.       printf("Round 2 earnings = 0\n");
  70.    }
  71.    printf("\n");
  72.    
  73.    scanf("%d",&bet3);//inputting the bet number
  74.    scanf("%d",&amount3);//inputting the bet amount
  75.    totalmoneyspent = totalmoneyspent + amount3;
  76.    winningnumber = rand() % 38;//randomly assigning the winningnumber
  77.  
  78.    //Calculating the total amount earned in this round
  79.    //Printing the values of bet number , bet amount , earning of this round
  80.    if(winningnumber == bet3){
  81.       roundamount = 5 * amount3;
  82.       total = total + roundamount;
  83.       printf("Round 3 number = %d\n",bet3);
  84.       printf("Round 3 bet amount = %d\n",amount3);
  85.       printf("Round 3 earnings = %d\n",roundamount);
  86.    }
  87.    else{
  88.       printf("Round 3 number = %d\n",bet3);
  89.       printf("Round 3 bet amount = %d\n",amount3);
  90.       printf("Round 3 earnings = 0\n");
  91.    }
  92.    printf("\n");
  93.    
  94.    scanf("%d",&bet4);//inputting the bet number
  95.    scanf("%d",&amount4);//inputting the bet amount
  96.    totalmoneyspent = totalmoneyspent + amount4;
  97.    winningnumber = rand() % 38;//randomly assigning the winningnumber
  98.  
  99.    //Calculating the total amount earned in this round
  100.    //Printing the values of bet number , bet amount , earning of this round
  101.    if(winningnumber == bet4){
  102.       roundamount = 5 * amount4;
  103.       total = total + roundamount;
  104.       printf("Round 4 number = %d\n",bet4);
  105.       printf("Round 4 bet amount = %d\n",amount4);
  106.       printf("Round 4 earnings = %d\n",roundamount);
  107.    }
  108.    else{
  109.       printf("Round 4 number = %d\n",bet4);
  110.       printf("Round 4 bet amount = %d\n",amount4);
  111.       printf("Round 4 earnings = 0\n");
  112.    }
  113.    printf("\n");
  114.    
  115.    //Calculating the total loss or profit
  116.    if(totalmoneyspent > total){
  117.       printf("Total Loss = %d\n",totalmoneyspent - total);
  118.    }
  119.    else{
  120.       printf("Total Profit = %d\n",total - totalmoneyspent);
  121.    }
  122.    
  123.    
  124.    
  125.    return 0;
  126. }