Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <ctype.h>
  5. #include <time.h>
  6.  
  7.  
  8. int main ()
  9. {
  10.     int i,diceRoll, sum1,sum2;
  11.     char choice;
  12.  
  13.     for(i = 1; i<=100; i++);
  14.     {
  15.         diceRoll = (rand()%6) + 1;
  16.         printf("%d", diceRoll);
  17.         diceRoll+= sum1;
  18.     }
  19.     printf("\nSum is %d", sum1);
  20.     printf("\n\nWill the next sum of dice rolls be higher, lower, or the same? (h/l/s)\n");
  21.     scanf("%c", &choice);
  22.  
  23.     for (i=1 ; i<=3; i++);{
  24.  
  25.         diceRoll = (rand()%6) + 1;
  26.         printf("%d", diceRoll);
  27.         diceRoll+= sum2;
  28.  
  29.     }
  30.  
  31.     switch(choice){
  32.  
  33.     case('h'):
  34.         printf("%s", (sum1<sum2) ? "Right" : "wrong");
  35.         break;
  36.     case('l'):
  37.         printf("%s", (sum1>sum2) ? "Right" : "wrong");
  38.         break;
  39.     case('s'):
  40.         printf("%s", (sum1==sum2) ? "Right" : "wrong");
  41.         break;
  42.  
  43.  
  44.     default:
  45.         printf("Didnt get that");
  46.  
  47.  
  48.  
  49.     }
  50.  
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement