Title: Arrays Declaration Examples
Course: CPS 120: Introduction to Computer Science ~ Master (Aug/2015) OLD > Section: Learning Units

Array declaration examples:

Array declaration examples
int Scores[4]; | Declares an array named Scores to hold four integer values.
double Salaries[100]; | Declares an array named Salaries to hold 100 double values.
string DaysOfWeek[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; | Declares an array named DaysOfWeek to hold seven string values, and assigns initial values.
char Vowels[5] = {'a','e','i','o','u'}; | Declares an array named Vowels to hold five char values, and assigns initial values.
bool Flags[8]; | Declares an array named Flags to hold eight bool values.

- In Visual C++, the size in the array declaration indicates that space for exactly which size elements will be created.
- When a Visual C++ array is declared, space is reserved for its elements.  Unless assigned specific values in the declaration, no initial values are assigned to the elements – they contain junk.