# roll dice program Lesson 38 challenge

 Venkatraman Mathur Narayanaswamy · January 16, 2015 Hi,Thanks for giving all the challenges since only when I practice I am able to figure out the nuances of 'c' programming --------------------------------------------------------------------------------------------------------------------------------------------------------------------#include #include #include #include #include /*commentsthis is rolldice program*/int main(){    int i;    int diceRoll;    int totRoll;    int randVal;    char diceFlag;    int totalGuess;    int cont = 0;    do {        printf("Enter a guess of the total value (Enter 6 to 36) ");        scanf(" %d",&totalGuess);        }while(totalGuess>=37 || totalGuess <5);    printf("Enter if total value will be (H-Higher L-Lesser S-Same) any other value to Exit? \n");    printf("(any other value to Exit) \n");    scanf(" %c",&diceFlag);     printf("Dice Flag:%c \n", diceFlag);    do {        totRoll = 0;         for(i=0;i<6;i++){                randVal = ((double)rand() / ((double)RAND_MAX + 1) * 6);                diceRoll = (randVal%6)+1;                totRoll += diceRoll;                printf("Random Value:%d \t Dice:%d \t Cum.Total:%d \n",randVal,diceRoll,totRoll);        }        printf("Final Total: %d \n",totRoll);        if ((totRoll>totalGuess) && (diceFlag == 'H')){            printf("Good Job the value derived is higher than the guess value \n");            printf("Derived Total:%d \t Original guess:%d \t Dice Flag:%c \n",totRoll,totalGuess,diceFlag);        } else if ((totRoll

## Replies

Nothing to see here.

## C

124,573 followers