title: Counting the frequency of an elements in an array
body: <p>Hello I am currently stuck on a homework problem as I have no idea how exactly to approach the problem.</p>
  
  <p>Write a program that reads in a list of integers into an array with base type
  int. Provide the facility to either read this array from the keyboard or
  from a file, at the user’s option. If the user chooses file input, the program
  should request a file name. You may assume that there are fewer than 50
  entries in the array. Your program determines how many entries there are.
  The output is to be a two-column list. The first column is a list of the distinct
  array elements; the second column is the count of the number of
  occurrences of each element. The list should be sorted on entries in the
  first column, largest to smallest.</p>
  
  <p>So I were to enter: 1, 2, 1, 10, 15, 12, 2, 10, 10
  The program should output something like:</p>
  
  <p>List Frequency</p>
  
  <p>1-----2</p>
  
  <p>2-----2</p>
  
  <p>10----3</p>
  
  <p>15----1</p>
  
  <p>I am able to sort the numbers but don't know how I would go about comparing the numbers in the array.</p>
  
  <pre><code>#include &lt;iostream&gt;//Input/Output Library
  #include &lt;cstdlib&gt;
  #include &lt;iomanip&gt;
  using namespace std;//Namespace of the System Libraries
  
  //Global Constants
  const int MAX = 10;
  
  //Function Prototypes
  void input(int array[], int size);
  void sort(int array[],int size);
  
  int main(int argc, char** argv){
      //Declare Variable
      int array[MAX];
      int size = MAX;
  
      //Input Data
      input(array, size);
      sort(array, size);
  
      cout&lt;&lt;"\nSort   Frequency\n";
      for(int i = 0; i&lt;size; i++){
          cout&lt;&lt;array[i]&lt;&lt;endl;
      }
  
      return 0;
  }
  
  void input(int a[], int size){
      cout&lt;&lt;"Enter "&lt;&lt;size&lt;&lt;" numbers for the array: \n";
      for(int i=0; i&lt;size; i++){
          cin&gt;&gt;a[i];
      }
  }
  void sort(int a[],int n){
      for(int i=0;i&lt;n-1;i++){
          for(int j=i+1;j&lt;n;j++){
              if(a[i]&gt;a[j]){
                  a[i]=a[i]^a[j];
                  a[j]=a[i]^a[j];
                  a[i]=a[i]^a[j];
              }
          }
      }
  }
  </code></pre>