I'm working on a rolling dice program. The rules are below. I'm not sure how to reassign a value. For example, a value of 1 and 2, would equal 1; a value of 3 and 4, would equal 2; and a value of 5 and 6, would equal 3.

The Rules Are:
- 3 die
- Roll 1 = value 1 and 2
- Roll 2 = value 3 and 4
- Roll 3 = value 5 and 6

This is the code I have so far:

    int R1 = 0;  
    int R2 = 0;  
    int R3 = 0;  


    while (( R1 <= 0 ) || ( R1 >= 7 ))  {   
        printf( "Enter a value [1-6] to roll the dice: " );   
        scanf( "%d", &R1 ); 
    }   

    while (( R2 <= 0 ) || ( R2 >= 7 ))  {   
        printf( "Enter a value [1 - 6] to roll the dice: " );  
        scanf( "%d", &R2 ); 
    }   

    while (( R3 <= 0 ) || ( R3 >= 7 ))  {   
        printf( "Enter a value [1 - 6] to roll the dice: " );   
        scanf( "%d", &R3 ); 
    } 

Just use if-else-if-else statements. ie, if (R1 < 2) val = 1; etc.

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.