1.0+Declaring+Arrays

Before you embarked on this topic, you should be relatively competent at selection and iteration constructs. You will need to make use of them in this topic.
 * Prerequisite:**

 It is a data type. Arrays are variables containing several homogeneous data types.
 * What is an array?**

Here are examples of an array: 1) An array of integers: {1,4,5,-4,10} 2) An array of characters (a, H, u, j, i)

These are not arrays: 1) {a, 1, 3, 5, 6} ==> Because it contains a character 'a' while the others are integers. 2) {1.1, 5, 7, 8} ===> Because it contains integers and floats. An array can only contain 1 data type.



When we learn about arrays we need to know the followings:


 * 1) How to declare an array?
 * 2) How to initialized an array?
 * 3) How to access elements in an array?
 * 4) How to make changes to elements of an array?

These are the fundamentals across any languages. Do you remember how to do them in C? We will go through them step by step before we embarked on its applications.

To declare an array is to know the syntax in that particular language for declaring. For Visual C++, Syntax:
 * How to declare an array?**

 Data Type Array_Name [X];

An example will be,

int Class[10]; => This is an array of 10 integers with array name class.

Practice questions to test understanding, send in your suggestions under discussion page 1) Declare an array of 12 characters name Month. 2) Mandy needs to create a data type to store at max 40 numbers which are weights for each students in the class. Suggest an appropriate data type. 3) Explain bool Ans[12];

It is good programming practice to initialize newly declared arrays with default values. We will do so in the next page ..... Go to Manipulating Arrays Page for more

media type="youtube" key="BqU3_ouKHwk" height="360" width="580"

media type="youtube" key="mYOCSu0rhAk" height="364" width="445"