What is array and why array in c?

An array is derived data type in c programming language which can store similar type of data in continuous memory location. Data may be primitive type (int, char, float, double…), address of union, structure, pointer, function or another array.

Example of array declaration:
int arr[5];
char arr[5];
float arr[5];
long double arr[5];
char * arr[5];
int (arr[])();
double ** arr[5];

Array is useful when:
(a) We have to store large number of data of similar type. If we have large number of similar kind of variable then it is very difficult to remember name of all variables and write the program.
(b)We want to store large number of data in continuous memory location. Array always stores data in continuous memory location.

Advantages of using array:
1. An array provides single name .So it easy to remember the name of all element of an array.
2. Array name gives base address of an array .So with the help increment operator we can visit one by one all the element of an array.
3. Array has many application data structure.

Definition of variable in C programming language 

Is a two dimensional array passed as a value or reference argument to a function?

Explain the following statement of C: int (*x) [20]


No comments:

Post a Comment