Dice Roll Program in C
I wouldn't recommend C or C++ as a starter language.
Try to reimplement the game in Python or Java or some other high level language.


You can use a loop instead of repeating yourself with die 1 die 2 and die 3.
Use a function for rolling and reporting.
The main loop can be a for loop that scanf()s the number of guesses and counts down.
A switch statement on the guess token could come in handy.




#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;time.h&gt;

#define N_DICE 3

/* Conveniently return the sum. */
int roll_dice(int *dice)
{
    int i, sum;
    for (i = sum = 0; i &lt; N_DICE; i++)
    {
        dice[i] = rand()%6 + 1;
        sum += dice[i];
    }
    return sum;
}

void print_dice(int *dice, int sum)
{ 
    int i;
    printf("\n\n");
    for (i = 0; i &lt; N_DICE; i++)
        printf("Die %d: %d\n", i + 1, dice[i]);
    printf("-------------------\nTotal: %d\n\n", sum);
}

int main()
{
    int runs, dice[N_DICE], sum, old_sum, correct, correct_guesses;
    char guess;

    srand(time(NULL));
    correct_guesses = 0;
    sum = roll_dice(dice);

    printf("How many times do you want to play? ");
    for (scanf("%d", &amp;runs); runs; runs--)
    {
        print_dice(dice, sum);
        old_sum = sum;
        sum = roll_dice(dice);

        printf(
            "Do you think the next total will be higher, "
            "the same, or lower than the previous total? "
            "(h, s, l)\n"
        );
        scanf(" %c", &amp;guess);
        switch (guess)
        {
            case 'h': correct = sum &gt; old_sum; break;
            case 's': correct = sum == old_sum; break;
            case 'l': correct = sum &lt; old_sum; break;
            default: correct = 0; printf("Not h, s or l.\n");
        }
        if (correct)
        {
            printf("You guessed correctly!\n");
            correct_guesses++;
        }
        else
            printf("You guessed incorrectly!\n");
    }
    printf("You got a total of %d guesses correct!\n", correct_guesses);
}