If you are having trouble with the algorithm, here is some help:
Keep a list (array) of all unique values you've read from the file. You'll also need to keep a count of how many times you read each value. When you read a value from the file, see if it's in the list. If it is, increment its "count". If it's not in the list, then add it to the list and set its "count" to 1.
If you are having trouble with the implementation, post some non-working code that shows you made an honest effort and someone will help you get it right.
Your for() loops aren't quite right. You've read all the values into an array a. Now it looks like you are going through each element and counting how many times that value occurs in the array, and keeping track of the one with the most occurrences. But your algorithm isn't quite right. Here is some pseudo-code that does what you need.
mode_count = 0; // Tracks the # of times the mode value occurred
mode_index = -1; // Tracks the index in the array of the mode value
for-each-element-in-array( A ) { // Let's call this index "target"
this_values_occurrences = 0;
for-each-element-in-array( A ) { // Let's call this index "search"
if( array[ search ] == array[ target ] ) // Is this value we're looking for?
++this_values_occurrences;
}
if( this value had more occurrences than mode_count ) {
mode_count = this_values_occurrences;
mode_index = target;
}
}
// Now mode_count is the number of times the mode value occurred
// and mode_index is the index in the array of the mode value.
// Note that if mode_index == -1 here, either you have a bug in your
// code or the array size was 0.