Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <time.h>
- //This code is unsophisticated!
- int main(){
- int i;
- int diceRoll1;
- int diceRoll2;
- int diceRoll3;
- int sum1;
- int sum2;
- char bet;
- srand(time(NULL));
- for (i=0; i<1;i++){
- diceRoll1 = rand()%6+1;
- diceRoll2 = rand()%6+1;
- diceRoll3 = rand()%6+1;
- sum1 = diceRoll1+diceRoll2+diceRoll3;
- printf("%d is the sum of the 1st roll. \n", sum1);
- }
- do{
- for (i=0; i<1;i++){
- printf("Do you think the next sum will be higher or lower?(y/n) \n", bet);
- scanf(" %c", &bet);
- diceRoll1 = rand()%6+1;
- diceRoll2 = rand()%6+1;
- diceRoll3 = rand()%6+1;
- sum2 = diceRoll1+diceRoll2+diceRoll3;
- printf("%d is the sum of the 2nd roll. \n", sum2);
- }
- }while(bet != 'y' && bet != 'n');
- if(((sum1 > sum2) && (bet=='y')) || ((sum2 > sum1) && (bet=='n'))){
- printf("You guessed wrong!\n");
- }else{
- printf("You guessed right!\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement