2016-11-06 09:07:16 UTC
NOTE: The mode is the value that occurs most frequently.
EXAMPLE: Given "msft" "appl" "msft" "csco" "ibm" "csco" "msft", the mode is "msft" because it appears the most number of times in the list.
My Code :
char* modeList[n] = {"msft", "appl", "msft", "csco", "ibm", "csco", "msft"};
std::string x[n];
int mode1count = 0;
int mode2count = 0;
int mode3count = 0;
int mode4count = 0;
int i;
for(i = 0; i < n; ++i)
x[i] = modeList[i];
for(i = 0; i < n; ++i)
{
if(x[i] == "msft")
++mode1count;
else if(x[i] == "appl")
++mode2count;
else if(x[i] == "csco")
++mode3count;
else if(x[i] == "imb")
++mode4count;
}