Electrical and Computer Engineering
8 of 17
UAH
CPE 112
Examples of Declaring and
Accessing Arrays
•const int BUILDING_SIZE = 350;
•int occupants[BUILDING_SIZE];
•int totalOccupants;
•int counter;
•totalOccupants = 0;
•for (counter = 0; counter < BUILDING_SIZE; counter++)
• totalOccupants = totalOccupants + occupants[counter];
•
•
•enum Drink {ORANGE, COLA, ROOT_BEER, GINGER_ALE, CHERRY, LEMON};
•float salesAmt[6];
•for (flavor = ORANGE; flavor <= LEMON; flavor = Drink(flavor + 1))
•   cout << salesAmt[flavor] << endl;