Question #341225

Write a program that uses a for statement to find the smallest of several integers.


Assume that the first value read specifies the number of values remaining and that the


first number is not one of the integers to compare.



Expert's answer

int min(int *arr){
   int min = INT_MAX;
   int n = arr[0];
   
   for(int i = 1; i <= n; i++){
      if(arr[i] < min){
         min = arr[i];
      }
   }
   
   return min;
}
LATEST TUTORIALS
APPROVED BY CLIENTS