Original Post
can som1 pls try this code or tell me why I get a memory error when I run it?
thanx in advance for any help
[edited by - Da Cobra on March 18, 2003 11:37:41 AM]
#include <time.h>
#include <stdlib.h>
#include <iostream.h>
void main()
{
// *** initialisation ***
int dice[10] ;
int counter = 0 ;
int three = 0 ;
int six = 0 ;
// *** generate 10 random numbers ***
for (counter = 1; counter <= 10; counter++)
{
srand ((unsigned)time(NULL)) ;
dice[counter] = rand()%6 + 1;
if (dice[counter] == 3)
{
three = three + 1 ;
}
else
if (dice[counter] == 6)
{
six = six + 1 ;
}
}
// *** output ***
system("cls") ;
for (counter = 1; counter <= 10; counter++)
{
cout << "Dice " << counter << " = " << dice[counter] << endl ;
}
cout << endl ;
cout << "thrown a 3 : " << three << endl ;
cout << "thrown a 6 : " << six << endl ;
}