Select Page

Is array a Data Type or Data Structure?

Team 1 - Programming
Published: August 25, 2022

View Discussion

Improve Article

Save Article

Like Article

View Discussion

Improve Article

Save Article

Like Article

What is Data Type?

A data type defines the type of value that can be stored in a variable. Whenever a variable is defined, the compiler allocates some memory for that variable based on the data type with which it is declared. Every data type requires a different amount of memory.

All these data types hold different values depending on their types. Some examples are shown below: 

Data TypeUsed ForExample
Integer Whole Numbers. . ., 0, 1, 2, 3, . . . N where N is any integer
Floating pointDecimal NumbersAny Real Number
BooleanRepresents Logical Values True or False
CharacterEncoding text numerically

‘a’, ‘1’ ,or any other character 

Note: Here 1 is also a character because 
it is enclosed between single quotes

A data structure is a storage that is used to store and organize data. It is a way of arranging data on a computer so that it can be accessed and updated efficiently. A data structure is not only used for organizing the data. It is also used for processing, retrieving, and storing data. There are different basic and advanced types of data structures that are used in almost every program or software system that has been developed. So we must have good knowledge about data structures. 

Some Examples of Data Structures are:

An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together. This makes it easier to calculate the position of each element by simply adding an offset to a base value, i.e., the memory location of the first element of the array (generally denoted by the name of the array).

Is Array Data Type or Data Structure?

Now since we have basic information about both data types and data structures, we can thereby conclude that array is undoubtedly a Data Structure because 

It can store values of any data type which we can access, delete and update the existing values also we can add on new values into it.

Hence array is a Data Structure and not a Data Type.

Source: www.geeksforgeeks.org