c program write a void function called maxlndex to accept an
c program
 write a void function called maxlndex to accept an array and return the value and the index of that value using reference parameters.
c program
 declare an array of size 200. place random values in each location in the range 1 to 6. save the frequency of each number in another array called frequency.
Solution
#include \"stdio.h\"
 #include \"time.h\"
 #include \"stdlib.h\"
void maxIndex( int* array, int size, int *max, int *index ){
    *max = array[0];
    *index = 0;
    int i = 1;
    for(; i < size; i++ ){
        if( array[i] > *max ){
            *max = array[i];
            *index = i;
        }
    }
 }
void frequencyForArraySize200( int frequency[7] ){
    srand( time(NULL ));
    int array[200];
    int i = 0;
    for(; i < 200; i++){
        array[i] = rand()%6 + 1;
    }
    i = 0;
    for(; i < 7; i++){ frequency[i] = 0;   }
    i = 0;
    for(; i < 200; i++){
        frequency[ array[i] ]++;
    }
 }
 int main(){
   int array[5] = {3,4,2,3,5};
    int max, index;
    maxIndex( array, sizeof(array)/sizeof(array[0]), &max, &index);
    printf(\"Max value %d occurs at index %d\ \", max, index );
   int freq[7];
    frequencyForArraySize200( freq );
    int i = 1;
    printf(\"\ \");
    for(; i < 7; i++){
        printf(\"Frequency of number %d is %d\ \", i, freq[i]);
    }
    printf(\"\ \");
 }

