Saturday, 20 June 2015

Arrays in Programming

Aggregated datatype of

  • Homogeneous type of elements: Array
  • Heterogeneous type of elements: Structure
Arrays

Arrays have fixed size and sequentially indexed

int a[10]; 

It says that a is the variable which contains 10 integer values which are contiguously stored in memory. 

Each element can be thought of as a variable. '&' is used to get location in the memory.

Note: We assign value from a[0] to a[9] and we cannot assign value for a[10].
We may have arrays of 2D and 3D

Generic Programs

#define N 6

Preprocessor replace the value of N with 6 where ever it comes in program
When ever we change source code of the program, we need to save, recompile and run.

Arrays can also be used as Counters








 

No comments:

Post a Comment