// // Filename: pgm4_2a.cpp // // Description: Passing Arrays #1 // // ENSC 104: Digital Computer Programming // // Instructor: Dr. Walsh // // Section: 2 // // Date Created: 03/28/98 // Last Modified: 03/28/98 // // Name: N/A // #include #include #include const int NUM_ELEMENTS = 10; // // The following are prototypes for functions that accept an // array as an argument. // void generateCharArray( char [], int ); void generateIntArray( int [], int ); void generateDoubleArray( double [], int ); main() { char c_array[NUM_ELEMENTS]; int i_array[NUM_ELEMENTS]; double d_array[NUM_ELEMENTS]; srand( time( NULL ) ); generateCharArray( c_array, NUM_ELEMENTS ); generateIntArray( i_array, NUM_ELEMENTS ); generateDoubleArray( d_array, NUM_ELEMENTS ); return 0; } void generateCharArray( char c_a[], int n ) { // // The following block of code randomly generates lower case // lettes of the alphabet. Note from page 889 in your text, the // ASCII table, the ASCII codes for the characters are 97 to 122. // The following code randonly generates an integer between 97 // and 122 and type casts it to a char. // cout << "\n\n***** Randomly Generating Characters *****\n\n"; for( int i=0; i> int_min; cout << "\tEnter the maximum integer value: "; cin >> int_max; cout << endl; int_range = int_max - int_min; for( int i=0; i> d_min; cout << "\tEnter the maximum double value: "; cin >> d_max; cout << endl; d_range = d_max - d_min; int_min = d_min * 1000; int_max = d_max * 1000; int_range = int_max - int_min; for( int i=0; i