Because it needs to compate to smaller values on your code.
:::
if u get value 20 its smaller than the infinite so it will be replaced
but if its 0
0 is not smaller than 20 so nothing will happen
hope that u understand
We have fixed nothing. We are someone too and we tell you.
Option 1 was to use the first real value. Problem is that then you have to treat the first input differently from the others.
Option 2 is to initialize with a good default and treat every input the same way. Simpler code with less repetition means less errors.
numeric_limits<int>::max() is a good default for minimum.
There is no possibility that all of input would be larger than that. (10000000 is not a good default.)
If every input equals the default, then the default truly equals the smallest input.
If any input is smaller than default, then the minimum will be updated and you get a real answer.