title: Find the longest arithmetic progression from an array
body: <p>I have an array of numbers ex.[5,1,2,4,6,8,12], and I want to find the length of longest arithmetic progression within the sequence and to print it. Longest arithmetic progression means an increasing sequence with common difference, in this case [2,4,6,8].</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void main()
  {
      int array[100], i, num,diff;
      printf("Enter the size of an array \n");
  
      scanf("%d", &amp;num);
  
      printf("Enter the elements of the array \n");
  
      for (i = 0; i &lt; num; i++) {
          scanf("%d", &amp;array[i]);
      }
  
      printf("\n Numbers in a.p: ");
  
      for (i = 0; i &lt; num; i++) {
          diff = array[i+1]-array[i];
          if (array[i]-diff == array[i+1]-diff);
          {
              printf("%d, ", array[i]);
          }
      }
      printf("\n Common difference:%d", diff);
  }
  </code></pre>