DO NOT MISS

Ads

Thursday, 23 June 2016

Data Types


The kind of data that variables may hold in a programming language is called data types.

(or)

Which defines the type of the data to be stored in computer memory.
There are three types of Data types.
Those are

1) Basic (or) Predefined Data types:-
These Data types are already defined.
Those are

All C compilers supports four fundamental data types namely int( ), char ( ), float ( ), double ( ).



a) Int:-
Integers are with range of values supported by a particular machine. Integers consists of set of digits. 0-9 in orders to provide some control the range of numbers storage space, 'C' has 3 classes of integer storage namely, short int, long int, in both signed & unsigned forms.



 i) signed int (or)int:-
We can create signed integer variable using signed int or int keywords. It occupies 2 bytes in memory space & it allows +ve or -ve values. It's range is -32,768 to +32,767

ii) unsigned int:
We can create unsigned integer variables using unsigned keyword. It occupies 2 bytes in memory space and it allows +ve or -ve values. It's range is 0 to 65,535.

iii) signed long int (or) long int (or) long:-
We can create signed long integer variables using long int keywords. It occupies 4 bytes in memory space and it allows +ve/-ve values. It's range -2,147,483 to 2,147,483.

iv) unsigned long int (or) unsigned long:-
We can create unsigned long integer variable using unsigned long int keyword. It occupies 4-bytes & allows only non -ve values. It's range 0 to 4,294,967,295 

v) signed short int (or) short:-
We can create signed short integer variables using keyword signed short int. It occupies 1 byte in memory it allows only +ve & -ve values. It range is -128 to 127.

vi) unsigned short int:-
We can create unsigned short int variables using unsigned short int keyword. It occupies 1 byte and it allows only +ve values. It's range is 0 to 255.
Data Type
Size (bytes)
Range
int (or) signed int

2
-32,768 to 32767
unsigned int

2
0 to 65535
short int 

(or)

signed short int



1
-128 to 127
long int 

(or) 

signed long int


4
-2,147,483,648

 to

2,147,483,647
unsigned long int
4
0 to 4,294,967,295

b) Float:-
We can create float type variables using the keyword float. Floating point numbers are stored in 4 bytes with 6 digits of precision. It allows +ve/-ve values.

i) double:-
We can create double data type variable using the keyword double. It occupies 8 bytes. It allows +ve/-ve values. These are stored with 16 digits of precision.

ii) long double:-
We can create long double data types variables using long double keywords. It occupies 10 bytes & it's allows +ve/-ve values.

Type
Size
(bytes)
Range

Float


4


3.4E-38 to 3.4E+38


double


8

1.7E-308 to 1.7E+308
long double

10

3.4E-4932 to 1.1E+4932

c) Char:-
A single character can be defined as a char data types. char are usually stored one byte of integer storage.
The character data types are 2 types.

i) signed char:-
It occupies 1 byte. It range is -128 to 127.

ii) unsigned char:-
It occupies 1 byte. It range is 0 to 255.

Type
Size
(bytes)
Range

char or signed char


1

-128 to 127

unsigned char


1

0 to 255

d) Void:-
It occupies 0 bytes & it's range is Zero.  
2) Derived data types:-

The derived data types are created from the basic integers, characters and floating values. The examples of derived data types are arrays, pointer, functions, structures, unions, etc.


3)User defined data types:-

The user defined data types enable a program to invent his own data types and define what values it can taken on. 

Thus this data types can help a programmer to reducing the programming errors. There are two types of user defined data types .

Those are

1. enum (enumerated data type) 

2. typedef (type definition)


__________________________________________________________________________________
__________________________________________________________________________________

Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims