Hello all,

int main()
{
    int how_many = 100;
        
    cout << "Print " << how_many << " random integers.\n";
    
    for (int i = 0; i < how_many; ++i)
    cout << rand() << '\t';

I need to add code to the above programm that determines the average, 
maximum and minimum values generated by the above programm.
The programm below is what I have so far and seems that i can't get 
through. Please I need your help.
This is what I have:

  /*The program determines average, maximum, and minimum values 
generated by 100 random numbers.*/ 
 
/*Begin of pre-processing directive block*/
#include <iostream>
#include <stdio.h> 
#include <stdlib.h> 
using namespace std;
/*End of pre-processing directive block*/

/*Begin of main function*/
int main()
{
    int how_many = 100;
    int max, min, ave;
    
    cout << "Print " << how_many << " random integers.\n";
    
    for (int i = 0; i < how_many; ++i)
    cout << rand() << '\t';
    for (int i = 0; i < how_many; ++i)
    if (rand(i) < rand(i+1))
       max = rand(i+1);
    else 
       min = rand(i);
       
   ave = (max - min) / 100;
   cout << "The maximum value generated = " << max << endl;
   cout << "The manimum value generated = " << min << endl;
   cout << "The average value generated = " << ave << endl; 
       
    system("PAUSE");
    return 0;
} // End of main function 

Please help!!!

Reply via email to