<mosaic.cnfolio.com>
PROGRAM
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. int main(void)
  5. {
  6. int bet1;
  7. int bet2;
  8. int bet3;
  9. int bet4;
  10. int cash1;
  11. int cash2;
  12. int cash3;
  13. int cash4;
  14. int profitloss1=0;
  15. int profitloss2=0;
  16. int profitloss3=0;
  17. int profitloss4=0;
  18. int totalprofitloss;
  19. int cashwon1=0;
  20. int cashwon2=0;
  21. int cashwon3=0;
  22. int cashwon4=0;
  23. int totalcashwon;
  24. int P;
  25. srand(time(NULL));
  26. P=rand()%1+3;
  27. printf("Welcome to the casino\n Please enter 4 bets\n");
  28. scanf("%d",&bet1);
  29. scanf("%d",&cash1);
  30. scanf("%d",&bet2);
  31. scanf("%d",&cash2);
  32. scanf("%d",&bet3);
  33. scanf("%d",&cash3);
  34. scanf("%d",&bet4);
  35. scanf("%d",&cash4);
  36. printf("the winning number is %d\n",P);
  37. if(bet1==P)
  38. {cashwon1=(cash1*35);
  39. printf("bet 1 has won!! %d\n",cashwon1);
  40. profitloss1=-1*cashwon1;
  41. printf("profit is %d \n",cashwon1);
  42. printf("loss is %d\n",profitloss1);}
  43. else
  44. { printf("bet 1 has lost.\n");
  45. cashwon1=0;
  46. profitloss1=-1*cashwon1;
  47. printf("profit is %d \n",cashwon1);
  48. printf("loss is %d\n",profitloss1);
  49. }
  50. if(bet2==P)
  51. {cashwon2=(cash2*35);
  52. printf("bet 2 has won!! %d\n",cashwon2);
  53. profitloss2=-1*cashwon2;
  54. printf("profit is %d\n",cashwon2);
  55. printf("loss is %d\n",profitloss2);}
  56. else
  57. { printf("bet 2 has lost.\n");
  58. cashwon2=0;
  59. profitloss2=-1*cashwon2;
  60. printf("profit is %d \n",cashwon2);
  61. printf("loss is %d\n",profitloss2);
  62. }
  63. if(bet3==P)
  64. {
  65. cashwon3=(cash3*35);
  66. printf("bet 3 has won!! %d\n",cashwon3);
  67. profitloss3=-1*cashwon3;
  68. printf("profit is %d\n",cashwon3);
  69. printf("loss is %d\n",profitloss3);}
  70. else
  71. { printf("bet 3 has lost.\n");
  72. cashwon3=0;
  73. profitloss3=-1*cashwon3;
  74. printf("profit is %d\n",cashwon3);
  75. printf("loss is %d\n",profitloss3);
  76. }
  77. if(bet4==P)
  78. {cashwon4=(cash4*35);
  79. printf("bet 4 has won!! %d\n",cashwon4);
  80. profitloss4=-1*cashwon4;
  81. printf("profit is %d\n",cashwon4);
  82. printf("loss is %d\n",profitloss4);}
  83. else
  84. { printf("bet 4 has lost.\n");
  85. cashwon4=0;
  86. profitloss4=-1*cashwon4;
  87. printf("profit is %d \n",cashwon4);
  88. printf("loss is %d\n",profitloss4);
  89. }
  90.  
  91. totalcashwon=cashwon1+cashwon2+cashwon3+cashwon4;
  92. totalprofitloss=totalcashwon-(cash1+cash2+cash3+cash4);
  93. }