// ;----------------------------------------------------------- // ; Program Name: Class_Demo // ; File: Demoprob8.cpp // ; Description: Performs a random roll if a die // ; // ; Author: Jim Adams // ; Assignment: None // ; Environment: MS C++ 6.0 // ; Revisions: 07/21/2001 Original version // ;----------------------------------------------------------- #include // has cout stuff #include // Has srand function #include // has time funstions unsigned x; int roll; void main( void ) { cout << "Simulate 100 rolls of a die\n"; srand( (unsigned)time( NULL ) ); for(x = 0; x<100; x++ ) { roll = rand() % 6 + 1; if (roll > 6) cout << "Bad Roll\n"; if (roll == 0) cout << "Bad Roll\n"; cout << roll << endl; } }