Contact Us || Privacy Policy || About Us |
|
What is an Array in CAn array is a collection of same data types that is store value in single variable. Advantage of Array1) Code Optimization: Less code for access the data. 2) Ease of traversing: Easily we can retrieve the elements of an array . 3) Ease for sorting: To sort the elements you can use few lines of code only. 4) Random Access: We can access any element randomly using the array. Disadvantage of C ArrayFixed Size: We are define at the time of declaration of the array, we can't exceed the limit. So, it doesn't grow the size dynamically like LinkedList . Declaration of ArrayWe are declare an array in the following way. Now, let see the example to declare the array. Initialization of ArrayExample1Output 10 20 30 35 45 Array Declaration with InitializationWe can initialize the an array at the time of declaration. if they are not define the size So it may also be written as the following code. Example2Output 20 30 40 50 60 Sorting Example an arrayOutput Printing Sorted Element List ... 101 78 44 34 23 23 12 10 9 7 |