C++ Array Finds the largest value

Description

C++ Array Finds the largest value

#include <iostream>
using namespace std;
const int SIZE = 15;
void main()/*  w w  w.  j a  va 2  s . c  o m*/
{
   // Puts some numbers in the array.
   int ara[SIZE]={5,2,7,8,36,4,2,86,11,43,22,12,45,6,85};
   int high_val, ctr;
   high_val = ara[0];           // Initializes with first array element.
   for (ctr=1; ctr<SIZE; ctr++){// Stores current value if it is the higher than the highest.
       if (ara[ctr] > high_val)
       {
          high_val = ara[ctr];
       }
   }
   cout << "The highest number in the list is " << high_val << "\n";
   return;
}



PreviousNext

Related