rolling dice program

This is a discussion on rolling dice program within the C Programming forums, part of the General Programming Boards category; : hi. im trying to work on a program our teach gave us. i need to wite a program in ...

rolling dice program

: hi. im trying to work on a program our teach gave us. i need to wite a program in C, which simulates the rolling of two dice. the program shiuold use rand to roll the first die and use rand again to roll second die. the sum shukld tehn be calculated. the progms shuld roll the two dice 36000 times. we have to use standard librairies, we are jsut learning C . so if ANYONE knows how to do this, or knows if there is a place where i can get help, please do tell! thanks you some, pelse do respond. please, this is worth 150 points and i only have 2 progects. adn this is our first one, i ahve one mroe some otehr time. but this will really count! plesae thank u . i jsut dont know how to do this , if someone can help me , it will be greatly appreciated , thank you.

i think this is the algorithm so far :

: : initialize an int array with 36000 elements if you need to store them, otherwise declare a single int.
: : seed the generator using srand
: : while an array element is empty or if no array just let it loop 36000 times(a for loop will work great here, but any will do)
: : -get random number and put it in the current array element or the int
: : - if you need to print it, use printf() to print it out.

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

The first thing to realize is that computer generated random numbers are not random. Speaking strictly abstract, there is no such thing as a random number, but realistically a random number is a sequence of independent values with a specific distribution (ie. obtained by chance and having nothing to do with the other numbers in the sequence).

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

EDIT: My roll() function might be a really poor way to get proper randomness, because those results look suspicious to me.

EDIT 2: At least I'm getting suspicious results consistently! I ran the program with the same parameters at least a dozen times and the graph at the end looks identical every time, the sum frequencies are so close to the same on every run.

Nevermind, I'm retarded. Of course 1 and 2 come up twice as often. For each die I'm pulling 3 bits of the number giving me possible 0 through 7. I add 1 to that which gives me 1 through 8. And then I just assign the die with the remainder of that number divided by 6, which means the die ends up being 1 or 2 if the original number was any of 1, 2, 7, or 8. I just need a better method

If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein