Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <time.h>
- #include <stdlib.h>
- int main()
- {
- int n=3,i,total=0,total2=0;
- time_t t;
- char ch;
- srand((unsigned)time(&t));
- for(i=0;i<3;i++) {
- total+=rand()%6 +1;
- }
- printf("Sum is %d\n",total);
- printf("Will the next sum of dice rolls be higher, lower, or the same? (h/l/s)\n");
- for(i=0;i<3;i++) {
- total2+=rand()%6+1;
- }
- ch=getch();
- switch(ch)
- {
- case 'h':
- if(total2>total)
- printf("Right!\n");
- else if(total2<total)
- printf("Wrong!\n");
- printf("The 2nd number was : %d\n",total2);
- break;
- case 'l':
- if(total2<total)
- printf("Right!\n");
- else
- printf("Wrong!\n");
- printf("The 2nd number was : %d\n",total2);
- break;
- case 's':
- if(total2==total)
- printf("Right!\n");
- else
- printf("Wrong!\n");
- printf("The 2nd number was : %d\n",total2);
- break;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement