What are the disadvantages of linked lists

Advantages and disadvantages of arrays in C programming

Go to content

advantages

  • It is a better and more convenient way to store data of the same data type with the same size.
  • It allows us to store known number of items in it.
  • It allocates memory in contiguous locations for its elements. It does not allocate additional space / storage for its elements. Therefore there is no memory overflow or memory shortage in arrays.
  • Iterating the arrays using their index is faster than other methods like linked lists etc.
  • It allows the elements to be stored in any dimensional array - supports multi-dimensional arrays.

disadvantage

  • It allows us to enter only a fixed number of elements. We cannot resize the array once the array is declared. So if we have to insert more records than declared, this is not possible. We should know the array size by ourselves at compile time.
  • Inserting and deleting the records from the array would be costly as we need to add / delete the items to the array and also manage the storage space.
  • The indexes are not checked when the array is compiled. If indexes larger than the specified dimension are referenced, run-time errors are displayed instead of being identified at compile time.

Important information about arrays

  • Array indices always start with 0. So if we say an array of size 10, the array contains elements from index 0 to 9. If we write the array as intArr [10], intArr [11], intArr [200], the C- Compiler, Specify, or Use does not display an error, but displays run-time errors while the program is running.
  • Arrays are supported by primitive data types, not primitive types like structures, unions, pointers, and so on
Catalog C programming tutorial
Scroll up