Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<conio.h>
- #include<math.h>
- void main()
- {
- int i, diceA,diceB, diceC,diceD,diceE,diceF,Total,Total2;
- char guess;
- printf("You rolled 3 dice and the result is: \n\n");
- for(i=0;i<5;i++)
- {
- diceA=(srand()% 6)+ 1;
- diceB=(srand()% 6)+ 1;
- diceC=(srand()% 6)+ 1;
- }
- printf("The result of dice A is: % d\n",diceA);
- printf("The result of dice B is: % d\n",diceB);
- printf("The result of dice C is: % d\n",diceC);
- Total= diceA+diceB+diceC;
- printf("The total obtained in this round is % d\n\n",Total);
- printf("The next dice is going to be rolled\n\n");
- printf("Can you guess the next roll? \n\n");
- printf("Will it be higher, lower or same? \n\n");
- diceD=(rand()% 6)+ 1;
- diceE=(rand()% 6)+ 1;
- diceF=(rand()% 6)+ 1;
- Total2= diceC+diceD+diceE;
- printf("Enter h for higher, l for lower and s for same ^_^\n\n");
- scanf("% s",guess);
- printf("The result of dice A is: % d\n",diceD);
- printf("The result of dice B is: % d\n",diceE);
- printf("The result of dice C is: % d\n",diceF);
- printf("The total of this round is % d\n",Total2);
- if (Total2 > Total){
- if(guess == 'h'){
- printf("Good Job\n");
- }
- else{
- printf("You suck!\n");
- }
- }
- if (Total2 < Total){
- if(guess == 'l'){
- printf("Good Job!\n\n");
- }
- else{
- printf("You suck!\n\n");
- }
- }
- if (Total2 == Total){
- if(guess == 's'){
- printf("Good Job!\n\n");
- }
- else{
- printf("You suck!\n\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement