[rps-include post=6557]
Arrays are different from primitive types like integer,chars. Arrays provides fixed length sequential data. All of the data is same type. We can think array like a same type list. Arrays uses indexes to specify specific item in array.
Declaring Arrays
There is two must do to define array. One is the type of the array and second is length of the array. Basic syntax of defining array is like below;
type array_name[length];
For example if we want to define an integer type array with 10 items we can use following code.
int numbers[10];
As another example to define and float array to store average temprature for 31 days we can use following array
float temprature[31];
After defining arrays according to their types and sizes some storage is allocated in memory. So while developing C programs array types and sizes must be set cautiously because it can creates low memory problems.
Initializing Arrays
Initializing means setting values to the newly created array. Arrays in C can be initialized in different ways.
Loop Through Arrays
As we know arrays are sequential data types. Looping through arrays are very popular and useful way to consume array data. We will look some examples about how to enumerate array data with loops.
Multidimensional Arrays
Arrays are accessed with index numbers. Arrays those have single line of data are named single dimension arrays. Arrays can be used int matrix or similar structure operations without using multiple arrays. More than one line of arrays are called multi dimension arrays.
type variable_name[size1][size2]...;
As we see we add new brackets according to dimensions. If there is more than 2 dimensions we will add more [size] brackets.
[rps-include post=6557]