title: Trying to find Frequency of elements in array
body: <p>I am trying to count how many times a number appears in an array 1 (a1) and then trying to print out that number by storing it in array 2 (a2) just once and then try to print array 2. But first using for loop and a function,  I will check that if a number already exist in array 2 then move to next index in array 1, unfortunateley this code is not working; can someone please help me in trying to fix it, I don't need some complex solutions like dictionaries or lists athe moment, although it might be helpful too. thanks, <strong>I am not an expert in programming and I try to practise it in my free time, so please help me.
  I just want this code to be fixed for my understanding and knowledge</strong></p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          int i, j;
          int[] a1 = new int[10];
          int[] a2 = new int[10];
          int[] a3 = new int[10];
  
  
          //takes an input
          for (i = 0; i &lt; a1.Length; i++)
          {
              a1[i] = Convert.ToInt32(Console.ReadLine());
          }
  
          for (i = 0; i &lt; a1.Length; i++)
          {
              Cn(a1, a2); //calls in function
              i++; //increments is if true
              int count = 0;
  
                  for (j = 0; j &lt; a1.Length; j++)
                  {
                      //if a number matches with a number in second array
                      if (a1[i] == a1[j]) 
                      {   
                          //do count ++
                          count++;
                      // store that number into second array
                      a2[i] = a1[i];
  
  
                  }
              }
  
                  //store the number of counts in third array
              a3[i] = count;
  
  
          }          
  
  
          for (i = 0; i &lt; a2.Length; i++)
          {
              if (a2[i] != 0)
              {
                  Console.WriteLine(a2[i]);
              }
          }
  
          Console.ReadLine();
      }
  
      //function to check if element at current index of array 1 exists in array 2 if yes than break
  
      public static void Cn (int[] aa1, int [] aa2) 
      {
  
          int k, j;
          for ( k = 0; k &lt; aa1.Length; k++)
          {
              for (j = 0; j &lt; aa2.Length; j++)
              {
                  if (aa1[k] == aa2[j])
                      break;
              }
  
  
          }
      }
  
  }
  </code></pre>