title: Finding the Index of the Min/Max Value in an Array C++
body: <p>So I'm trying to figure out how to get the min/max value of an array, and get the corresponding index value. I also am not sure how to call that function in my main function. My trouble is in the final part of the problem statement. I put it in block quotes. I started to make the getHighest function, but I don't know where to go or if I am even doing it right. Any help appreciated.</p>
  
  <pre><code>//Write a program that uses a structure to store the following information, for 
  //a particular month, at the local airport:
  // Total number of planes that landed
  // Total number of planes that departed
  // Greatest number of planes that landed in a given day that month
  // Least number of planes that landed in a given day that month
  //The program should have an array of twelve structures to hold travel information 
  //for the entire year. The program should prompt the user to enter data for each 
  //month. Once all data is entered, the program should calculate and output the average 
  //monthly number of landing planes, the average monthly number of departing planes, 
  //the total number of landing and departing planes for the year, and 
  </code></pre>
  
  <blockquote>
    <p>the greatest and 
        least number of planes that landed on any one day (and which month it occurred in).</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  using namespace std;
  
  const int NUM_MONTHS = 2;
  
  struct AirportData
  {
      int planesLanded;
      int planesDeparted;
      int mostPlanesLanded;
      int leastPlanesLanded;
  };
  
  // Function Prototypes
  void getHighest(int AirportData array[], int size);
  void getLowest();
  double getLandingAverage(int landedSum, int NUM_MONTHS);
  double getDepartedAverage(int departedSum, int NUM_MONTHS);
  
  int main()
  {
      int landedSum = 0;
      int departedSum = 0;
      int totalPlanes = 0;
      double average = 0.0;
      AirportData travelInformation[NUM_MONTHS];
  
      // Get user input
      for(int i = 0; i &lt; NUM_MONTHS; i++)
      {
          cout &lt;&lt; "How many planes landed in month " &lt;&lt; i + 1 &lt;&lt; " ? ";
          cin &gt;&gt; travelInformation[i].planesLanded;
  
          cout &lt;&lt; "How many planes departed in month " &lt;&lt; i + 1 &lt;&lt; " ? ";
          cin &gt;&gt; travelInformation[i].planesDeparted;
  
          cout &lt;&lt; "What is the greatest number of planes that landed "
               &lt;&lt; "on a given day in month " &lt;&lt; i + 1 &lt;&lt; " ? ";
          cin &gt;&gt; travelInformation[i].mostPlanesLanded;
  
          cout &lt;&lt; "What is the least number of planes that landed "
               &lt;&lt; "on a given dey in month " &lt;&lt; i + 1 &lt;&lt; " ? ";
          cin &gt;&gt; travelInformation[i].leastPlanesLanded;
  
          cout &lt;&lt; endl;
      }
  
      // Calculate the Sum
      for(int i = 0; i &lt; NUM_MONTHS; i++)
      {
          landedSum = landedSum + travelInformation[i].planesLanded;
          departedSum = departedSum + travelInformation[i].planesDeparted;
      }
  
      // Calculate the total amount of planes landed and departed YTD
      totalPlanes = landedSum + departedSum;
  
      // Output the results
      cout &lt;&lt; endl;
      cout &lt;&lt; "The average number of monthly landing planes is: "
               &lt;&lt; getLandingAverage(landedSum, NUM_MONTHS) &lt;&lt; endl;
      cout &lt;&lt; "The average number of monthly departed planes is: "
               &lt;&lt; getDepartedAverage(departedSum, NUM_MONTHS) &lt;&lt; endl;
      cout &lt;&lt; "Landing and Departing Planes this Year: " &lt;&lt; totalPlanes &lt;&lt; endl;
  
  
      return 0;
  }
  
  // getHighest() function - Get's the most planes landed on a given day and outputs
  
  
      void getHighest(AirportData array[], int size)
  {
      int highest = 0;
      int maxIndex = 0;
  
      for(int i = 0; i &lt; NUM_MONTHS; i++)
      {
          if(array[i].mostDailyLanded &gt; highest)
          {
              highest = array[i].mostDailyLanded;
              maxIndex = i + 1;
          }
      }
      cout &lt;&lt; "The greatest number of planes that landed on a day was " &lt;&lt; highest
           &lt;&lt; " in Month " &lt;&lt; maxIndex &lt;&lt; endl;
  }
  
  // getLowest() function - Get's the least planes landed on a given day and outputs
  void getLowest(AirportData array[], int size)
  {
      int lowest = array[1].leastDailyLanded;
      int maxIndex = 0;
  
      for(int i = 0; i &lt; NUM_MONTHS; i++)
      {
          if(array[i].leastDailyLanded &lt; lowest)
          {
              lowest = array[i].leastDailyLanded;
              maxIndex = i + 1;
          }
      }
      cout &lt;&lt; "The least number of planes that landed on a day was " &lt;&lt; lowest
           &lt;&lt; " in Month " &lt;&lt; maxIndex &lt;&lt; endl;
  }
  
  
  // getLandingAverage() function - Get's the average monthly planes landed
  double getLandingAverage(int landedSum, int NUM_MONTHS)
  {
      return landedSum/NUM_MONTHS;
  }
  
  // getDepartedAverage() function - Get's the average monthly planes departed
  double getDepartedAverage(int departedSum, int NUM_MONTHS)
  {
      return departedSum/NUM_MONTHS;
  }
  </code></pre>