Can u guyz help me for this problem

Write a function that given an array, returns both the minimum and maximum values in the list. Your main program should allow the user to enter space-separated numbers as test lists, until a blank line is entered.
Sample output of the program:
List: 3 6 9 2 4 6
min =2, max = 9

min =2, max = 9


Help me guys

1 Like

In Python you can directly use min() and max() function for this task.
or Go for iterative method:

  1. assign min = max = List[0]
  2. for each element in List:
    if element < min : min = element
    if element > max: max = element
  3. print(min,max)

void min_max(int arr[], int n)
int min,max;
for(int i=1; i<n; i++){
min = arr[i];
printf("Minimum ",min);
printf("Maximum ",max);