# Challenge #2, done? I also have a few questions!

 Jacky L · February 19, 2015 So here is my code:    #include     #include     #include     #include     #include     #include     int main(void)    {        int i;        int roll1;    int roll2;    int sum1 = 0;    int sum2 = 0;    char input;    for( i = 0; i < 3; i++ ) {        roll1 = ( rand()%6 ) + 1;        printf( "Roll number #%d. ", i+1);        printf( "You rolled a %d.\n", roll1);        sum1 += roll1;    }    printf("Sum: %d\n", sum1);    printf("Will your next dice roll sum be higher, lower, or the same as %d? (h/l/s)\n", sum1);    scanf("%s", &input);    i = 0;    for( i = 0; i < 3; i++ ) {        roll2 = ( rand()%6 ) + 1;        printf( "Roll number #%d. ", i+1);        printf( "You rolled a %d.\n", roll2);        sum2 += roll2;    }    printf("New sum: %d\n", sum2);    //higher    if (sum2 > sum1){        if(input == 'h'){            printf("Lucky guess\n");        }        else{            printf("You suck!\n");        }    }    //lesser    if (sum2 < sum1){        if(input == 'l'){            printf("Lucky guess!\n");        }        else{            printf("You suck!\n");        }    }    //same    if (sum2 == sum1){        if(input == 's'){            printf("Lucky guess!\n");        }        else{            printf("You suck!\n");        }    }    return 0;}So I don't really get a random number each time my program is executed. I keep getting 6,6,5 as my first roll and then 6,5,6 for my second roll

• 1

## C

120,736 followers

One of the most popular languages of all time.