Menu
Coddy logo textTech

Min-Max Difference

Lesson 9 of 11 in Coddy's Bubble Sort course.

challenge icon

Challenge

Easy

Create a function named min_max that receives an array and size of the array. Output the difference between the maximum and minimum element of the array. 

Sample Input: [3,2,5,3,6]

Max Element is 6, Min Element is 2.

Difference is 6-2=4

Output: 4

Try it yourself

#include <stdio.h>
#include <stdlib.h>

int min_max(int* arr, int arr_size, int n) {
    // Write code here
    return 0;
}

All lessons in Bubble Sort