The code is almost correct ,but just has the prob with "min" variables initial value.
To identify the "max" value you initialised it to least value possible.The same logic can be worked backwards to conclude that - to identify the "min" value you should initialise it to the greatest value possible.
Ie code should be like --->
int min = 999999;//Greatest value possible hence
//all other values in the range
//are lesser than min
int max =-999999;//Least value possible hence
//all other values in the range
//are greater than max