Check out example codes for "c++ program how to let the user choose different game modes". It will help you in understanding the concepts better.

Code Example 1

int getMode(int *virus, int *frequency, int numVir)
{
   int count = 0,
	   index = 0,
	   mode = 0,
	   frLow = 0,
           total = 0;

   for (index = 0; index < numVir; index++)
   {
	  count = 1;

	  while (*(virus + index) == *(virus + index + 1))
	  {
		 ++count;
		 ++index;
	  }
	  
	  *(frequency + index) = count;
	  
	  if (*(frequency + index) > frLow)
	  {
		 frLow = *(frequency + index);
                 total += *(frequency + index);
		 mode = *(virus + index);
	  }

	  else if (frLow == 1 || frLow == *(frequency + index))
	  {
		 return -1;
	  }
   }

    return mode;
}

Learn ReactJs, React Native from akashmittal.com