title: How to return largest two numbers in array in C?
body: <p>So, I have this so far. I'm trying to find the two largest numbers in an array and return them. I looked up a lot of resources online, and most of them say "call by reference" is the way to go. But I've no idea how to make it work with my program. For example, I saw this example online:</p>
  
  <pre><code>void Calculate(int x, int y, int* prod, int* quot)
  {
      *prod = x*y;
      *quot = x/y;
  }
  
  int x = 10,y = 2, prod, quot;
  Calculate(x, y, &amp;prod, &amp;quot)
  </code></pre>
  
  <p>How does the above program actually "return"? How do I print the return values to the console? </p>
  
  <pre><code>#include "stdio.h"
  
  
  void largest_two( int numbers[], int len, int *largest, int *next_largest){
  
  
    int i, temp;
  
    *largest = numbers[0];
    *next_largest = numbers[1];
  
    if(*largest &lt; *next_largest){
      temp = *next_largest;
      *largest = *next_largest;
      *next_largest = temp;
    }
  
    for (i=0; i&lt;sizeof(numbers); i++) {
      if(numbers[i]&gt;= *largest){
        *largest = numbers[i];
        *next_largest = *largest;
      }
      else if ( numbers[i] &gt; *next_largest){
        *next_largest = numbers[i];
      }
    }
  }
  
  int main() {
    int numbers[] = {3, 1, 2, 3, 6, 2, 8, 0, 0, 0};
    int len = 3;
    int largest, next_largest;
  
    //==&gt;??? printf("%d %d", largest_two(numbers, len, &amp;largest, &amp;next_largest));
  
    }
  </code></pre>