A data type refers to a collection of values that share a similar feature and therefore contain instructions, methods and abilities that those values can operate within. It organizes your code and its values so that you’re able to properly use the values.

Info

Although there are common data types across languages, how they are used and named may be completely different. Lower level languages, like C for example, may have more defined versions such as long vs short to allow for more precise memory control.

Table

Below is a table of common data types:

Data typeExampleExample languageDescription
shortshort x = 1C++, C#16 bits/ 2 bytes, refers to an integer within the range of -32,768 to 32,767
longlong x = 1C++, C#32 bits/ 4 bytes, refers to an integer within the range of -2,147,483,648 to 2,147,483,647
long longlong long x = 1C++64 bits/ 8 bytes, refers to an integer within the range of −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
intintC, C++, C#Standard 16 bits, refers to an integer.
arbitrary precision integersx:int = 1Python, Haskell, Lisp,Also known as infinite precision integers or bignums, these integer data types have no set range like the others defined above.
boolbool x = 1C, C++, C#Booleans have values either “1” or “0” - or a “true” and “false” respectively.
unsignedunsigned short x = 1C, C++Usually prefixing another integer data type, unsigned integers are always positive - therefore increasing the range of positive numbers.
floatfloat x = 1.5C, C++, C#Floating points refer to numbers with decimals to high precision.
charchat x = 'a'C, C++Represents a single character.
stringmsg:str = "hi!"PythonRepresents a string of characters.

Data structures:

Data structureExample
Description
ArrayC++: int[] = [1, 2, 3]
Python: python_list = [1, 2, 3]
Also known as a list, it represents a collection of values. Each value can be retrieved from the list by the ‘index’, which is the position of an element in the array usually counting up from 0.
Linked listexampleSimilar to an array, but contains a sequence of values.
RecordPython: my_tuple = (x, 2)
C++: struct{string x; int num;} my_structure
Also known as a struct or a tuple, a record can be displayed like a ‘coordinate’, or in a database - a ‘row’ and its subsequent ‘field’.
Hash tablesPython: my_dict = {"name": "Jay"}
Dart: Map<String, String> my_map = {"name": "Jay"}
Also known as a map or a dictionary, a hash table is a complex data structure built with ‘key: value’ pairs, meaning you can retrieve the value by calling its key (in the example, my_dict["name"] will retrieve Jay).
Graphsexamples
Visually, a graph by itself isn’t displayed like a graph in code. It will done with adjacency matrixes, lists, etc.

Graphs consists of ‘nodes’ (vertices) connected by ‘edges’, which can be used to map relationships between objects.
StacksPython:
my_stack = [1, 2, 3]
my_stack.pop() # pops out 3 from list
Stacks are lists following the principle of “last-in, first-out”.

Think of a stack of dirty dishes, the most recent dish to go on top will be cleaned first.
QueuePython:
my_queue = [1, 2, 3]
my_queue.pop(0)
OR
my_queue = deque([1, 2, 3])
my_queue.popleft()
Queues are lists following the principle of “first-in, first-out”.

Think of an actual queue, the person who gets in the queue first will get out of the queue first.