Home Forums C Programming I also need help..! Re: Re: I also need help..!

#3594
GWILouisaxwzkla
Participant

could try:


/****************************************************************
* File Name : c:programstempCG.cpp
* Date : july,21,2009
* Comments : new project
* Compiler/Assembler : Visual C++ 6.0
* Modifications :
*
*
*
*
*
* Program Shell Generated At: 12:05:56 a.m.
=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


#include
#include
#include
//#include
//#include
//#include

const MAX_SIZE = 10;
const int MAX_NUMBERS = 10;
using namespace std;

//main function ******************************

int main ( )
{

int numbers [ MAX_SIZE ];
int i;
int smallest , largest;
i = 1;
srand ( time ( NULL ) ); //seed random number generator
numbers [ 0 ] = rand () % MAX_NUMBERS;
smallest = largest = numbers [ 0 ]; //set smallest and largest for comparison
//generate random numbers
while ( i < MAX_SIZE )
{
numbers [ i ] = rand () % MAX_NUMBERS;
if ( numbers [ i ] > largest )
largest = numbers [ i ];
else if ( numbers [ i ] < smallest )
smallest = numbers [ i ];
i ++;
}
cout << "array generated: " << endl;
i = 0;
while ( i < MAX_NUMBERS )
{
cout << numbers [ i ] << " ";
i ++;
}
cout << endl << endl;
cout << "largest number was " << largest << endl;
cout << "smallest number was " << smallest << endl;

return 0 ;
}