<limits.h> has what you both are looking for; definitions of the minimum and maximum int values. Set the minimum to INT_MAX and the maximum to INT_MIN and be done with it.
There's a reason we all didn't just whip up the code for them in the first reply. It's not because we couldn't. It's because we wanted them to work it out for themselves. Now that you've gone and ruined it, we all may as well throw our hat into the ring.
Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<limits.h>
#define SIZE 100
#define RANDCAP 100
int main( void )
{
int array[ SIZE ] = {0},
min = INT_MAX,
max = INT_MIN,
mincount = 0,
maxcount = 0;
size_t x = 0;
srand( time( NULL ) );
for( x = 0; x < SIZE; x++ )
{
array[ x ] = rand( ) % RANDCAP;
if( array[ x ] < min )
{
min = array[ x ];
mincount = 0;
}
if( array[ x ] > max )
{
max = array[ x ];
maxcount = 0;
}
if( array[ x ] == min )
{
mincount++;
}
if( array[ x ] == max )
{
maxcount++;
}
}
printf( "min: %d, count: %d, max: %d, count: %d\n", min, mincount, max, maxcount );
return 0;
}
There you go, all in a single loop.
Edit: Looks like you replied before I did. :P
Quzah.