Hey guys, I'm new to programming and C, and I'm trying to write a program for a weighted dice, but I'm awful at math, and I can't figure out how to get it; it took my stupid self long enough to turn rand() into a number between 1 and 6. >.<

Can someone give me a nudge in the right direction?

I've got my

`d = rand() % 6 + 1;`

statement and I'm trying to weight the dice with an array of doubles that represent the probability of getting the number that corresponds to that array number.

For example:

`double p[6] = { 1./6, 1./6, 1./6, 1./6, 1./6, 1./6 };`

Would be a fair dice roll.

`double p[6] = { 0.0, 0.75, 0.0, 0.0, 0.0, 0.25};`

would be weighted with a 75% chance of getting a 2, and a 25% chance of getting a 6.

I feel really stupid that I can't figure this out. :(

Thanks so much!