#include #include using namespace std; int main ( ) // main loop { const int ArraySize = 20; // number of temperature values to input. used throughout to limit need for complete rewrites int ftemp[ArraySize]; // fahrenheit temperatures int ctemp[ArraySize]; // celsius temperatures int count; // reusable varianble for counter in loops int max = 0, min = 0; // variables for maximum and minimum array locations cout << "Please enter " << ArraySize << " Fahrenheit temps now." << endl; for ( count = 0 ; count < ArraySize ; count++ ) // loop through array { cout << "Add your temp #" << count + 1 << endl; cout << "==> "; cin >> ftemp[count]; // get F temperature ctemp[count] = (5/9)*(ftemp[count]-32); // convert to celsius } // output the temperature list cout << "Fahrenheit Temp \t Celsius Temp " << endl; for (count = 0; count < ArraySize; count++) { cout << "\t" << ftemp[count] << "\t\t\t" << ctemp[count] << endl; // formatted list } // find minimum and maximum value array locations for (count = 1; count < ArraySize; count++) { if ( ftemp[count] > ftemp[max] ) // kind of a bubble sort method max = count; // store the array location instead of the number if ( ftemp[count] < ftemp[min] ) // so that it works on both arrays min = count; } // output maximum and minimum vales from both lists cout << endl << "MAX:\t" << ftemp[max] << "\t\t\t" << ctemp[max] << endl; // uses the same formatting as the list, cout << "MIN:\t" << ftemp[min] << "\t\t\t" << ctemp[min] << endl; // separated by a single blank line system("PAUSE"); // the worst way to pause a program ever. shame on me for relying on MS-DOS system commands. return 0; }