this is my programm, there is a mistake because it doesn't give the right answer; the quetion is below the program:
#include<stdio.h>
#define maxsize 100
void fillarray(double*, int);
void getminmax(double*, double*, double*, int);
int main() {
double WinNum, WinP, grades[maxsize];
int size,num,i;
printf("\n how many players are there:");
scanf("%d", &size);
fillarray(grades, size);
getminmax(grades, &WinNum, &WinP, size);
printf("The Random Number is: ");
scanf("%d", &num);
printf("\n Winning Number:%.2f ** Winning Player:%.2f",WinNum,WinP);
}
void fillarray(double* grade, int asize){
int i;
for(i=0;i<asize;i++){
printf("Player %d: ",i+1);
scanf("%lf",&grade[i]);
}
}
void getminmax(double* grade, double* WinNum, double* WinP, int num){
int i;
*WinNum = grade[0];
for(i=1; i<num; i++){
if (grade[i]< num)
*WinNum = grade[i];
*WinP=i-1;
}
}
The question: Write a program that gets as input an array of integers where every integer represents a number and player. The function will output the winning number and the winning player,
the winning number in closet one to a certani random number(Generated by
rand()). the winning player is its subscript in the array .
embed your function in a working program.