Gabriel Leong · July 31, 2015 This is Bucky second challengeto guess if the next random total number is higher or lower then the previous rollthis is what i did but, even tho is rand(), it does seems to give same number every time, am i doing anything wrong?#include #include #include #include #include int main(){    int i;    int dice1;    int dice2;    int dice3;    int total1;    int total2;    char hl;    for (i=0; i<=9; i++){        dice1=(rand()%6) +1;        dice2=(rand()%6) +1;        dice3=(rand()%6) +1;        total1=dice1+dice2+dice3;        printf(" your total roll is : %d \n" ,total1);    }    printf("for the next roll, is total be high or low(press H/L) \n");    scanf(" %s" ,&hl);    dice1 =(rand()%6) + 1;    dice2 =(rand()%6) + 1;    dice3 =(rand()%6) + 1;    total2=dice1+dice2+dice3;    if(total1 > total2){        if(hl== 'L'){            printf("good job is %d", total2);        }else{        printf("u suck");        }    }else {    if(hl== 'H'){            printf("good job is %d", total2);        }else{        printf("u suck");        }    }    return 0;    }

## Replies

 Jon Z. · July 31, 2015 Include the time library.``#include ``and add the following line at the beginning of your main function, or anywhere before the rand function is called.``srand (time(NULL));``That should do the trick. Gabriel Leong · August 4, 2015 thanks it worked XD
• 1

## C

130,937 followers