Array max function working

I’m not able to understand working of this function.

Hi, all u are asked to find is the largest and the smallest no… let name variable of largest variable as largest and smallest as smallest… we initialize smallest to INT_MAX and largest to INT_MIN…
then just loop over array and
smallest = min(smallest, arr[i])
largest = max(largest, arr[i])
and u get the final ans…

Actually my question was we first fully loop over max function then move to min function or other way around ?

u can do that in one loop only like this

for(int i=0;i<n;i++){
     smallest = min(smallest, arr[i]);
     largest = max(largest, arr[i]);
}

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.