C++ Program to Calculate min & max values using loops

/** Calculate min & max values using loops **/

#include 
using namespace std;

int main() {

   cout << "Program to calculate min & max" << endl;
   cout << "in an array using loops" << endl << endl;

   int a[10];

   cout << "Enter 10 random integers..." << endl;
   for (int i=0; i> a[i];

   cout << "This is the array: " << endl;
   for (int i=0; i<10; i++)
     cout << a[i] << " ";
   cout << endl << endl;

   int min = a[1], max = a[1];
   // Find minumum and maximum
   for (int i=0; i max)
       max = a[i];

     if (a[i] < min)
       min = a[i];
   }

   cout << "Minimum: " << min << endl;
   cout << "Maximum: " << max << endl;

}

Advertisements