🌟 Join our Telegram group for exclusive updates! Join Now Get Involved

Array Basics

Array Basics

Array Basics

An array is a collection of data items of the same data type, also known as a subscript variable.

  • Items are stored at contiguous memory locations in arrays.
  • It can also store the collection of derived data types such as pointers, structures, etc.
  • The C Language places no limits on the number of dimensions in an array. This means we can create arrays of any number of dimensions, whether it's a 2D array, a 3D array, or more.

Dimensions of an array

  • A one-dimensional array is like a list.
  • A two-dimensional array is like a table.
  • Some texts refer to one-dimensional arrays as vectors and two-dimensional arrays as matrices, using the general term "arrays" when the number of dimensions is unspecified or unimportant.

How do Arrays help?

Programs that use arrays for managing a large number of the same data type variables are more organized and readable compared to creating different variables of the same type for each data element. Arrays allow us to create many variables with just a single line, eliminating the need to create or specify every variable.

Advantages of Arrays

  • It is used to represent multiple data items of the same type by using only a single name.
  • Accessing any random item at any random position in a given array is very fast.
  • There is no case of memory shortage or overflow in the case of arrays since the size is fixed, and elements are stored in contiguous memory locations.

Properties of Arrays

  • An array stores data of any data type in contiguous memory locations in RAM.
  • Each element of an array is of the same size, i.e., their data types are the same, so the memory consumed by each is also the same.
  • Any element of the array with a given index can be accessed very quickly by using its address, calculated using the base address and the index number.

Index Number: It is a special type of number that allows us to access variables of arrays. Index numbers provide a method to access each element of an array in a program.

Cookies Consent

This website uses cookies to ensure you get the best experience on our website.

Cookies Policy

We employ the use of cookies. By accessing BYTEFOXD9, you agreed to use cookies in agreement with the BYTEFOXD9's Privacy Policy.

Most interactive websites use cookies to let us retrieve the user’s details for each visit. Cookies are used by our website to enable the functionality of certain areas to make it easier for people visiting our website. Some of our affiliate/advertising partners may also use cookies.