Please help me!!
How do I sort rand() generated numbers to determine minimum, maxmum,
average values.
Below is my code which is not working on minimum and maximum values
/*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 min = 0;
int max = 0;
cout << "Print " << how_many << " random integers.\n" ;
int sum = 0;
for (int i = 0; i < how_many; i++)
{
cout << rand() << '\t';
sum = sum+rand();
if (rand() < ++rand())
max == ++rand();
else
min == rand();
}
int avg = sum / how_many;
cout << "Min = " << min << endl;
cout << "Max = " << max << endl;
cout << "Sum = " << sum << endl;
cout << "Average = " << avg << endl;
system("PAUSE");
return 0;
} // End of main function