#include <iostream>
#include <algorithm>
usingnamespace std;
void calculateMode(int, int);
int main()
{
int size;
int aaa;
cout << "I will find the mode of a list of data. How big is your list?\n";
cin >> size;
int findMode[size] = {};
for(int n = 0; n < size; n++ )
{
cin >> aaa;
findMode[n] = aaa;
}
sort(findMode,findMode + size);
calculateMode(findMode,size);
}
void calculateMode(int array[], int big)
{
int counter = 1;
int max = 0;
int mode = array[0];
for (int pass = 0; pass < big - 1; pass++)
{
if ( array[pass] == array[pass+1] )
{
counter++;
if ( counter > max )
{
max = counter;
mode = array[pass];
}
} else
counter = 1; // reset counter.
}
cout << "The mode is: " << mode << endl;
}
Any tips on formatting or syntax error. Thank you.