Data Types Tccicomputercoaching.com

A data type in a programming language is a set of data with values having predefined characteristics. Examples of data types are: integer, floating point unit number, character, string, and pointer. Usually, a limited number of such data types come built into a language.

When we write source code, compiler have to convert that source code into machine code. The data used in source code have to be differentiate as digit, real number or text (alphabetical) for compiler information. So, data are categorized as per their type. These data type have size, as per this size they have allocated memory.

In computer science and computer programming, a data type or simply type is a classification identifying one of various types of data, such as real, integer or Boolean, that determines the possible values for that type, the operations that can be done on values of that type, the meaning of the data, and the way values of that type can be stored.

Common data types include:

Integers

Booleans

Characters

Floating-point numbers

The type void

The type specifier void indicates that no value is available.

Primitive Types:

A basic type is a data type provided by a programming language as a basic building block. Most languages allow more complicated composite types to be recursively constructed starting from basic types.

A built-in type is a data type for which the programming language provides built-in support.

Type Storage size Value range
char 1 byte -128 to 127 or 0 to 255
unsigned char 1 byte 0 to 255
signed char 1 byte -128 to 127
int 2 or 4 bytes -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to 4,294,967,295
short 2 bytes -32,768 to 32,767
unsigned short 2 bytes 0 to 65,535
long 4 bytes -2,147,483,648 to 2,147,483,647
unsigned long 4 bytes 0 to 4,294,967,295

 

Composite types

Composite types are derived from more than one primitive type. This can be done in a number of ways. The ways they are combined are called data structures. Composing a primitive type into a compound type generally results in a new type, e.g. array-of-integer is a different type to integer.

An array stores a number of elements of the same type in a specific order. They are accessed randomly using an integer to specify which element is required (although the elements may be of almost any type). Arrays may be fixed-length or expandable.

A list is similar to an array, but its contents are strung together by a series of references to the next element.

Record (also called tuple or struct) Records are among the simplest data structures. A record is a value that contains other values, typically in fixed number and sequence and typically indexed by names. The elements of records are usually called fields or members.

Union. A union type definition will specify which of a number of permitted primitive types may be stored in its instances, e.g. “float or long integer”. Contrast with a record, which could be defined to contain a float and an integer; whereas, in a union, there is only one type allowed at a time.

A tagged union (also called a variant, variant record, discriminated union, or disjoint union) contains an additional field indicating its current type, for enhanced type safety.

A set is an abstract data structure that can store certain values, without any particular order, and no repeated values. Values themselves are not retrieved from sets, rather one tests a value for membership to obtain a Boolean “in” or “not in”.

An object contains a number of data fields, like a record, and also a number of subroutines for accessing or modifying them, called methods.

If you like this post then please like and share this post

Visit us @ tccicomputercoaching.com

Call us @ 98256 18292.

To Learn More About Computer Class, Computer Course

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s