English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
#include
#include
#include
#include

#define TRUE 1
#define FALSE 0
typedef int BOOL;
#define GetRandom( min, max ) ((rand() % (int)(((max) + 1) - (min))) + (min))


BOOL roll_dice_is_snake_eyes()
{
int d1,d2;

d1=GetRandom( 1, 6 );
d2=GetRandom( 1, 6 );
if(d1 == 1 && d2 == 1)
return TRUE;
return FALSE;
}


#define TRIES (1000L*1000L*1000L)

int main(int argc, char* argv[])
{
long i, sum=0;

printf("The probability that 2 dice will land snake eyes\n");

/* initialize/seed random number generator */
srand( (unsigned)time( NULL ) );

for(i=0; i {
if(roll_dice_is_snake_eyes())
sum++;
}

printf("\nIn %ld tries, dice came up snake eyes %ld times.\n",TRIES,sum);
printf("The probability is thus: %0.9f\n", (double)(sum) / (double)(TRIES));

getch();
return 0;
}


is there a certain way to do this i thought you had to start with main or something like that. i need like step by step instructions. i have never done this before

2007-12-02 06:23:17 · 1 answers · asked by eronau 2 in Computers & Internet Programming & Design

1 answers

You already have a main (read it closely)

Go download a compiler like Bloodshed C++ (no, I didn't make that up) and learn the general stuff like how to use it, THEN use that to enter your program. Don't use Word, for Pete's sake...

2007-12-02 06:50:15 · answer #1 · answered by Kasey C 7 · 0 0

fedest.com, questions and answers