Program's success on performing it's intended task is significantly affected by the choice of data types used in it's implementation. The data types used needs to match with the real life problems and entities being addressed. Most programming languages, therefore, offers various types of data types to address the wide range of programming problems . Most languages also allow users to define their own data types , or to modify existing ones in the language to match the problem at hand. Languages designed since 1980's also comes with inbuilt support for the concept of abstract data types. An Abstract data type provides an interface to which the data type being modeled must adhere without being language specific.
Primitive data types
Data types that are not implemented in term of other types are known as primitive data types. All programming languages provides a set of primitive data types which acts as the building blocks of more advanced ones.
Some primitive data types includes
Numeric types
Early programming languages only supported numerical data types, this is because numeric types are almost a reflection of the underlying hardware.
Integers
This is the most common primitive datatype, and the numbers they represents are same as mathematical integers . Most programming languages have size limits for integer types and they are usually categorized with the number of bits they occupy in the memory. Using this categorization we get short, int and long integers. Some high level languages like python provides an abstraction to integers, such that their size are literally unlimited and only one integer type exists.
Floats
Floating-point data types are used to model real numbers. They are usually represented using Float and Double types.
Complex
Some programming languages like python supports complex data types and their operations to model complex numbers. Complex numbers are numbers which are made up of real part and imaginary one. For example python the imaginary literal is followed by a j or J . For example ( 2 + 5j )
Boolean Types
This type has only two set of elements,one for true and one for false. If an operation evaluates to a non-zero value, it's boolean value will be true otherwise false. Boolean types are hugely used for conditional testing especially in branching program's logic.
Character type
Each character stored in computer is encoded to a numeric value .Characters refers to various letters, and other graphical symbols including ones used in representation of numeral values such as 'a', '#', '7' . The value assigned to a character depends on what encoding is used. An example of an encoding system is the ASCII which is an acronym for American Standard Code for Information Interchange. ASCII encodes only 128 specified characters including 0-9, a-z , A-Z and other non-printable characters , for example the character 'a' is assigned a numeral value of 97 .
ASCII's is much limited due to the small character set it represents and many computers today use Unicode system which encodes over a hundred thousand characters.
Composite data types
Composite data types also known as compound data types have one or more parts that is made using objects from another data type. Some composite data types includes:
Array
An array is simply contiguous locations in computer memory which are used to store a collection of homogeneous items. Contiguous here means that the items are stored next to each other at a specific section in the memory and by homogeneous we mean that the items need to be of the same types. Most programming languages supports the array data type in one way or another. Some languages may use an abstraction to the array to hide the low-level working details from the programmer, the best example of this is the python list type.
Strings
The string data type is used to represent a sequence of characters. The most basic implementation of strings is by arranging characters in an array and then putting a null character to mark where the string ends. Most high level languages today offers more robust implementation of the string data type so that one doesn't need to worry much about low-level implementation details.
linked lists.
While arrays, uses contagious locations in memory to store data, items in a linked lists are scattered across the computer's memory. Each item in a list stores alongside the value, an address where the next item in the linked list is stored. Linked lists and arrays are sort of complimentary, for example accessing an item in an array is computationally optimal while inserting and deleting data involves more overhead, because remaining items needs to be adjusted to accommodate the incoming item or to occupy the space left after an item is removed. On the other hand, inserting and deleting items in a linked list is computationally optimal while accessing items in the list involves traversing the list until the required item is reached.