Data types in computer

 

Data Types in Computer

In Computer language, whenever we create a variable to store any data or information, then while declaring that variable, we also have to declare what type of data that variable is going to store.


These data types can be int, char, float, double, by looking at these data types, it is known which type of value is going to be stored in the variable.


As we store Integer value in a variable made of int data type, in a variable made of char data type we store data of character type and in a variable made by Float data type we store floating point value. is |


While declaring a variable, we declare its type because when the compiler compiles our source code and converts it to machine code, then the compiler will allocate some memory in ram for that variable according to that data type.


A program may need to store many different types of data. According to the kind of data we have to store, we can use many types of data types . Let us now know how many types of data types are there

There are mainly three types of data types -:


Pre-defined data types

1. Predefined Data Types

2. Derived Data Types

3. User-defined data type


Such data types are called Pre-defined Data Types which are already defined and which do not need to be defined separately such as – int, char, float, double, void etc.

These data types come in Basic Data Types. The meaning of these data types does not have to be told to the compiler separately because they are already defined and such data types which are also keywords, those data types are called primitive data types.


List of Predefined Data Types 

Pre-defined Data TypesExamples
Integer Typeint, long int, short int, unsigned int 
Character Typechar
Floating Point Data TypeFloat , double 

Integer Type

The “int” keyword is used to create a variable of type Integer.

We store numeric value in the variable of Integer type.

Variable made of "int" data type can store 2 byte, 4 byte and 8 byte data. But this thing depends on the compiler.

Floating Point Data Type

There are two types of floating point data type -:

1.Float

2.Double


Float

It is used to store decimal point data.

The “float” keyword is used to create a variable of floating point type.

The size of the variable made of Float Type is 4 bytes.


Double

It is also used to store decimal point data like float data type.

The “double” keyword is used to create a variable of double data type.

The size of a variable made of double type is 8 bytes.


2. Derived Data Types

Derived Data Types are such data types in which there is a grouping of variables. The following are the Derived Data Types -:

1.Array

2.Function

3.Pointer

3. User-Defined Data Types

Such Data Types which are not already defined and which have to be defined separately are called User-Defined Data Types. Such as – Structure, Enumerator, union

Post a Comment

0 Comments