This message is appearing for each of my functions. Could someone explain what the issue is and how to fix it/ prevent it in the future?
Thank You. Here is my code:
Code:#include <iostream> #include <string> using namespace std; struct airport { float numLanded; float numDeparted; float greatestLanded; float leastLanded; }; float averageDeparture(airport, int); float averageLanded(airport, int); int greatestLanded(airport, int); int leastLanded(airport, int); int main() { string months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; airport statistics[12]; int totalLanded = 0; int totalDeparted = 0; int count; for (count = 9; count < 12; count++) { cout << "Please enter the number of planes that landed in " << months[count] << ": " << endl; cin >> statistics[count].numLanded; cout << "Please enter the number of planes that departed in " << months[count] << ": " << endl; cin >> statistics[count].numDeparted; cout << "Please enter the greatest number of planes that landed on a single day in " << months[count] << ": " << endl; cin >> statistics[count].greatestLanded; totalLanded += statistics[count].numLanded; totalDeparted += statistics[count].numDeparted; } cout << "The average monthly landings for the year is " << averageDeparture(statistics[count], count) << endl; cout << "The average monthly departures for the year is " << averageLanded(statistics[count], count) << endl; cout << "The total landings for the year is " << totalLanded << endl; cout << "The total departures for the year is " << totalDeparted << endl; cout << "The greatest number of planes that landed in a single day is " << greatestLanded(statistics[count], count) << " which occured in the month of " << months[count] << endl; cout << "The least number of planes that landed in a single day is " << leastLanded(statistics[count], count) << " which occured in the month of " << months[count] << endl; system("pause"); return 0; } float averageDeparture(airport array[], int pos) { float total = array[pos].numDeparted; return (total / 3); } float averageLanded(airport array[], int pos) { float total = array[pos].numDeparted; return (total / 3); } int greatestLanded(airport array[], int pos) { int max = 0; for (int i = 1; i < pos; i++) { if (array[i].numLanded > array[i + 1].numLanded) { max = array[i].numLanded; return max; } } } int leastLanded(airport array[], int pos) { int min = 0; for (int i = 1; i < pos; i++) { if (array[i].numLanded < array[i + 1].numLanded) { min = array[i].numLanded; return min; } } }




Reply With Quote
