Dice Rolling
Write a program that simulates the rolling of two dice. The program should use rand to roll the first die and should use rand again to roll the second die. The sum of the two value should then be calculated. [Note: Since each die can show an integer value from 1 to 6, then the sum of the two values will vary from 2 to 12 with 7 being the most frequent sum and 2 and 12 the least frequents sums.] There are 36 possible combinations of the two dice. Use an array to tally the numbers of times each possible sum appears. Print the result in tabular format.

Umm ... We're not going to just do your homework assignment for you. Try the assignment yourself, and post in the appropriate language forum (C++, Java, etc) along with what you've tried so far and exactly where you're stuck.

this is not my homework..but its just my exercise..i have done to built this..but it cant run properly..

#include <stdio.h>
#include <stdlib.h>
/* function main begins program execution */
int main(void)
{
    int frequency1 = 0; /* rolled 1 counter */
    int frequency2 = 0; /* rolled 2 counter */
    int frequency3 = 0; /* rolled 3 counter */
    int frequency4 = 0; /* rolled 4 counter */
    int frequency5 = 0; /* rolled 5 counter */
    int frequency6 = 0; /* rolled 6 counter */

    int roll; /* roll counter, value 1 to 36 */
    int face; /* represent one roll of the die, value 1 to 6*/

    /* loop 36 times and summarize results */
    for ( roll = 1; roll 36; roll++ ) {
        face = 1 + rand() % 6; /* random number from 1 to 6 */

        /* determine face value and increment appropriate counter */
        switch ( face ) {

            case 1: /* rolled 1 */
            ++ frequency1;
            break;

            case 2: /* rolled 2 */
            ++ frequency2;
            break;

            case 3: /* rolled 3 */
            ++ frequency3;
            break;

            case 4: /* rolled 4 */
            ++ frequency4;
            break;

            case 5; /* rolled 5 */
            ++ frequency5;
            break;

            case 6; /* rolled 6 */
            ++ frequency6;
            break; /* optional */
        } /* end switch */

    } /* end for */

    /* display results in tabular format */
    printf( "%s%13s\n", "Face", "Frequency" );
    printf( " 1%13d\n", frequency1 );
    printf( " 2%13d\n", frequency2 );
    printf( " 3%13d\n", frequency3 );
    printf( " 4%13d\n", frequency4 );
    printf( " 5%13d\n", frequency5 );
    printf( " 6%13d\n", frequency6 );

    return 0; /* indicates successful termination */

    /* end main */
}

can somebody help me and explain what the question want..i dont understand the question..

this is not my homework..but its just my exercise..i have done to built this..but it cant run properly..

Why not? We know less about your program than you do.

can somebody help me and explain what the question want..i dont understand the question..

Seems obvious to me. What you don't understand?

Do not give vague statements and expect us to understand what's in your mind. You need to explain and ask good, detailed questions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.