because i enjoy coding random stuff...
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define DICECOUNT 3
#define DICESIDES 6
#define SUCCESS "CORRECT."
#define FAILURE "FAIL."
int a, b, c, x, y; char guess;
int roll() {
return (rand() % (DICESIDES - 1 + 1)) + 1;
};
int rollDice(int diceAmount) {
int xx = 0;
for (int i=0; i < diceAmount; i++) {
xx += roll();
};
return xx;
};
int main() {
srand(time(0));
x = rollDice(DICECOUNT);
y = rollDice(DICECOUNT);
printf("NUMBER: %d\n", x);
printf("[h]igher, [l]ower or [s]ame ?");
scanf("%s",&guess);
printf("NUMBER: %d\n", y);
switch(guess) {
case 's':
if (x == y) {
printf("%s",SUCCESS);
} else {
printf("%s",FAILURE);
}
break;
case 'h':
if (y > x) {
printf("%s",SUCCESS);
} else {
printf("%s",FAILURE);
};
break;
case 'l':
if (x > y) {
printf("%s",SUCCESS);
} else {
printf("%s",FAILURE);
};
break;
};
return 0;
};