C C++ Java Data Structure Python JavaScript CSS Ajax PL/SQL PHP Puzzles C programs C++ programs Java programs

Home » C programming language

Properties/characteristics of an array in C language

Array properties/characteristics in C language: Here, we are going to learn what are some of the important properties/characteristics of an array data types in C programming language?

An array is defined as the group of similar data types, which takes contiguous memory locations. Array stores same kind of data.

It’s just normal definition, which you can find anywhere. Here, we are discussing some of the properties or characteristics of an array data type.

Properties/characteristics of an Array

1) An array is a derived data type, which is defined using basic data types like int, char, float and even structures (which is called the array of structures).

2) Array elements are stored in contiguous memory blocks/subsequent memory blocks in primary memory.

3) Array name represents its base address. The base address is the address of the first element of the array.

4) Array’s index starts with 0 and ends with N-1. Here, N stands for the number of elements. For Example, there is an integer array of 5 elements, then it’s indexing will be 0 to 4.

5) Only constants and literal values (an integer value like 5, 10, 12,...) can be assigned the number of elements in an array.

Consider the given code:

Valid array declarations:

int main()
	const int MAX = 100; //an integer constant
	//valid arrray declaration
	int students[MAX];
	//valid arrray declaration
	int students[100];

Invalid array declarations:

int main()
	int MAX = 100; //an integer constant
	//invalid arrray declaration
	int students[MAX];

6) While declaring an array, we can also assign each element with 0 like this.

Like: int age[10]={0};

7) There is no need to provide the number of elements while declaring an array, but we have to provide the values at the time of declaration. In this case, array size will be the number of values that you have provided.

Like: int age[]={21,22,25,45,56};

Here, size of the array will be 5, because there are 5 values.

8) An array can be allocated anywhere in these memory permanents:
A) Data segment for static or globally declare array
B) Heap segment for dynamically allocated array
C) Stack segment for locally declare array