Data Types in Programming Languages

Data Types; All the very complex programs which are present in the electrical devices and computers are composed of two basic items: Data and the operations which are performed on those Data.

Unlike human beings the computers do not know the difference between different data which are provided to it. A data type is a classification of the types of data provided that which operations can be performed on that specific data and how many bits of memory does it take. When a programmer types a code he must make the correct use of the data types in order to have an error-free program.

Data Types

For example; an “integer” is a data type which can only store whole numbers like 234 and 56. While “character” is used to store characters such as A, Z.

Classification of Data Types:



Primitive Data Types:

Also called the Basic Data Types!

  1. Machine Data Types:

All the data in computers based on the digital electronics is represented as bits which can only store 1 or 0. The two binary digits of 1 and 0 is also called to be the binary number system which is the language used in the computers. All the codes and programs that we write are converted into the binary language so that it should be understandable for the computer. The lowest addressable part of data in a computer is byte which is an octet or made up of 8 bits. Every single bit can store whether 1 or 0.

In High Level Languages the machine data types are basically hidden or abstracted.

  1. Boolean Data Types:

Boolean data type have got only two values of true and false. Not the strings “true” and “false” but the keywords true and false. In machine language the values true and false is represented by 1 and 0 correspondingly. But you should not be using 1 and 0 in your code. Instead you should make use of the keywords true and false.

Java Boolean Data Type

  1. Numeric Data Types:

Numeric data types are of the following types:

  • Integer data types:

They are the whole numbers, such as; “245” and “8”.

They can further be divided into short and long and signed and unsigned integers which basically depend on the type of the language you use to write your code.

  • Floating point data types:

They are basically used to store the fractional numbers or numbers with a decimal point. Its examples can be “23.56” or “7.01”. They are also called to be the real data types.

Numeric Data Types

  1. Character Data Types or Strings:

They are used to store a letter of the alphabets, punctuation marks, blank spaces or digits.

String data type is a sequence of characters which is mostly used to represent words and text. String is not a primitive data type. In languages like C, string is called to be an array of characters.

String Data Types

Composite Data Types:




They are composed of the Basic or Primitive Data Types. Some of them are:

  1. Array Data Type:

It is used to store a sequence of the same data types. It can be a sequence of integers or a sequence of characters (string). The elements stored in the array can be accessed randomly from any order.

See Also: [button link=”http://codejow.com/array-data-structure-explanation-c/” target=”self” color=”green” icon=”none” style=”normal” size=”default”]Array Data Structure in C++[/button]

  1. Linked List Data Type:

It is similar to an array data type. But you can store different data types into it also. The elements in the linked list are linked to each other by a series of references.

Linked List Data Types

  1. Record Data Type:

It is also called to be STRUCT in some languages. The members of a record data type is called fields. It is a value that can contain other values.

  1. Object Data Type:

It contains a number of data fields like the records and also a number of subroutines for accessing and modifying them.

Object Data Types

There are further data types also, such as Enumerated Data Types and Abstract Data Types which further include Unions, trees, stacks, Queues, sets and etc.

It is important to be noted that all the languages do not use all these data types. Specific languages use their own specific set of data. In order to make better use of the coding languages you need to know which set of data types are useful for the syntax of that specific language. Like; Object data types are used in Object Oriented Languages such as C++ and Java, while it is not supported by C language. On the other hand; C language can make use of STRUCT data types.

See Also: [button link=”http://codejow.com/make-series-prime-numbers-c/” target=”self” color=”green” icon=”none” style=”normal” size=”default”]Make a Series of Prime Numbers in C++[/button]

Comments

  • Leave a Reply

    %d bloggers like this: