### Max value is wrong cant find solution

Here is my code I can not find out way my max variable is wrong.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 5

int random(int [], int, int, int);
int display(int, int, int);

int main()
{
int number, total = 0;
int store[SIZE];

random(store, SIZE, number, total);

return 0;
}
int random(int arr[], int sz, int num, int sum)
{
int counter, mx = 50, mn = 1;
srand(time(NULL));
mx = num;
mn = num;

for(counter = 0;counter < sz;counter++)
{
num = 1 + rand() % 51;

printf("%d ", num);

arr[counter] = num;

if(num < mn)
mn = num;
if(num > mx)
mx = num;

sum = num + sum;
}
display(mn, mx, sum);

return 0;
}
int display(int x, int y, int z)
{
printf("\n\n");
printf("The min value is %d.\n", x);
printf("The max value is %d.\n", y);
printf("The total of numbers is %d.\n", z);
}
{
printf("This program generates 5 random numbers and stores them in an array.\n");
printf("Then determines which number is largest and smallest.\n\n");
}
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162`` ``````# include # include # include # include #define SIZE 5 int random(int);// You send only one value so you need one argument void display(int, int, int); void heading(); int main() { heading(); random(SIZE); return 0; } int random(int sz) { int counter = 0,sum = 0,arr[sz]; int mx = INT_MIN, mn = INT_MAX,num = 0; srand(time(NULL)); for(counter = 0;counter < sz;counter++) { num = 1 + rand() % 51; printf("%d ", num); arr[counter] = num; if(num < mn) mn = num; if(num > mx) mx = num; sum = num + sum; } display(mn, mx, sum); return 0; } void display(int x, int y, int z) { printf("\n\n"); printf("The min value is %d.\n", x); printf("The max value is %d.\n", y); printf("The total of numbers is %d.\n", z); // Return something or void this function } void heading() { printf("This program generates 5 random numbers and stores them in an array.\n"); printf("Then determines which number is largest and smallest.\n\n"); }``````