Header Ads Widget

Array in c

 what is array:-

Array is a finite collection of homogeneous elements in contiguous memory locations. Here finite means fixed and finite size (Finite number of elements).
Homogenous means all elements are of same datatype .
Contiguous memory location means consecutive memory locations. i.e. the elements will be store in sequence one after another in memory.
Array are of multiple types:-
1. 1D- Array
2. 2D - Array
3. 3D-Array
     --
     --
     --
   nD -Array

1. 1D array (one dimensional array):-
                                                                  Declaration syntax of a one dimensional array is as follow:-
a) declaration:-
 
syntax:-  Data_type    Array_name[Size];

Data_type:- it specifies the type of elements that will be stored in the array.
Array_name:- Specify the name of array which user defined.
Size:-  Specifies the number of elements in the array.

Example:-  int arr[5]; 
                    Here int is the datatype of the array elements, arr is the name of the array and 5 is the size of the array.
Let's say the base address of the array is 100 i.e. first element store at the address 100 in the memory then of this address of other elements are:-

2.  float b[5]; 
   As we know that floating point number takes 4 byte to store one number. but it varies with the architecture and it is for 16 bit architecture .

 <<Pre--Advantages and disadvantages of Recursion         Initialization of 1D array--Next>>


Recommended Post:

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-