Advertisement
Guest User

Untitled

a guest
Jun 4th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #include<math.h>
  4. void main()
  5. {
  6. int i, diceA,diceB, diceC,diceD,diceE,diceF,Total,Total2;
  7. char guess;
  8. printf("You rolled 3 dice and the result is: \n\n");
  9. for(i=0;i<5;i++)
  10. {
  11. diceA=(srand()% 6)+ 1;
  12. diceB=(srand()% 6)+ 1;
  13. diceC=(srand()% 6)+ 1;
  14. }
  15. printf("The result of dice A is: % d\n",diceA);
  16. printf("The result of dice B is: % d\n",diceB);
  17. printf("The result of dice C is: % d\n",diceC);
  18. Total= diceA+diceB+diceC;
  19. printf("The total obtained in this round is % d\n\n",Total);
  20.  
  21. printf("The next dice is going to be rolled\n\n");
  22.  
  23. printf("Can you guess the next roll? \n\n");
  24. printf("Will it be higher, lower or same? \n\n");
  25.  
  26. diceD=(rand()% 6)+ 1;
  27. diceE=(rand()% 6)+ 1;
  28. diceF=(rand()% 6)+ 1;
  29. Total2= diceC+diceD+diceE;
  30. printf("Enter h for higher, l for lower and s for same ^_^\n\n");
  31. scanf("% s",guess);
  32.  
  33. printf("The result of dice A is: % d\n",diceD);
  34. printf("The result of dice B is: % d\n",diceE);
  35. printf("The result of dice C is: % d\n",diceF);
  36.  
  37. printf("The total of this round is % d\n",Total2);
  38. if (Total2 > Total){
  39. if(guess == 'h'){
  40. printf("Good Job\n");
  41. }
  42. else{
  43. printf("You suck!\n");
  44. }
  45. }
  46. if (Total2 < Total){
  47. if(guess == 'l'){
  48. printf("Good Job!\n\n");
  49. }
  50. else{
  51. printf("You suck!\n\n");
  52. }
  53. }
  54. if (Total2 == Total){
  55. if(guess == 's'){
  56. printf("Good Job!\n\n");
  57. }
  58. else{
  59. printf("You suck!\n\n");
  60. }
  61. }
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement