C++ examples for Data Type:Array
Finds the largest value in the array.
#include <iostream> using namespace std; const int SIZE = 15; void main()// www. jav a 2 s . co 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; }