hi there, ARRAYS && POINTERS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sala
    New Member
    • Nov 2006
    • 12

    #1

    hi there, ARRAYS && POINTERS

    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(doubl e*, int);
    void getminmax(doubl e*, 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(grade s, size);
    getminmax(grade s, &WinNum, &WinP, size);
    printf("The Random Number is: ");
    scanf("%d", &num);
    printf("\n Winning Number:%.2f ** Winning Player:%.2f",Wi nNum,WinP);
    }
    void fillarray(doubl e* grade, int asize){
    int i;
    for(i=0;i<asize ;i++){
    printf("Player %d: ",i+1);
    scanf("%lf",&gr ade[i]);
    }
    }
    void getminmax(doubl e* 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(Generate d by
    rand()). the winning player is its subscript in the array .
    embed your function in a working program.
Working...