You can simply sort the random integers and then get the first and last
integer for Maximum and Minimum values. For Average you can use the
following code

 

 

int main()
{
int how_many = 100;

cout << "Print " << how_many << " random integers.\n";

int sum = 0;

for (int i = 0; i < how_many; i++)

{

cout << rand() << '\t';

sum = sum+rand();
}

 

int avg = sum / how_many;

 

cout << "Average" << avg;

 

Thanks,

Atul

 

  _____  

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of
fecress
Sent: Wednesday, March 12, 2008 11:28 PM
To: [email protected]
Subject: [c-prog] C++ Rand() function need help

 

int main()
{
int how_many = 100;

cout << "Print " << how_many << " random integers.\n";

for (int i = 0; i < how_many; ++i)
cout << rand() << '\t';

Please help me to add a code that determines average, maximum and 
minimum values generated by the program above.

 



[Non-text portions of this message have been removed]

Reply via email to