Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Programming Logic

Data Types

B.Bhuvaneswaran, AP (SG) / CSE


9791519152
bhuvaneswaran@rajalakshmi.edu.in
Data Types
 Basic (or primary or fundamental) data types:
• Integer (int)
• Character (char)
• Floating point (float) and
• Double floating point (double).
 Derived data types: Derived data types are pointers, functions and
arrays.
 User-defined types: struct, union and typedef are user-defined
data types.
 void data type

Data Types Rajalakshmi Engineering College 2


Size & Range of Data Types (Turbo C)
Type Length Range
unsigned char 8 bits 0 to 255
char (or) signed char 8 bits -128 to 127
unsigned int 16 bits 0 to 65,535
short (or) short int (or) signed short int 16 bits -32,768 to 32,767
int (or) signed int 16 bits -32,768 to 32,767
unsigned long (or) unsigned long int 32 bits 0 to 4,294,967,295
long (or) long int (or) signed long int 32 bits -2,147,483,648 to 2,147,483,647
3.4 *(10**-38) to 3.4 * (10**+38)
float 32 bits
3.4E-38 to 3.4E+38
1.7 * (10**-308) to 1.7 * (10**+308)
double 64 bits
1.7E-308 to 1.7E+308
3.4 * (10**-4932) to 1.1 * (10**+4932)
long double 80 bits
3.4E-4932 to 1.1E+4932

Data Types Rajalakshmi Engineering College 3


Size & Range of Data Types (gcc)
Type Length Range
unsigned char 8 bits 0 to 255
char (or) signed char 8 bits -128 to 127
unsigned int 32 bits 0 to 4,294,967,295
short (or) short int (or) signed short int 16 bits -32,768 to 32,767
int (or) signed int 32 bits -2,147,483,648 to 2,147,483,647
unsigned long (or) unsigned long int 32 bits 0 to 4,294,967,295
long (or) long int (or) signed long int 32 bits -2,147,483,648 to 2,147,483,647
3.4 *(10**-38) to 3.4 * (10**+38)
float 32 bits
3.4E-38 to 3.4E+38
1.7 * (10**-308) to 1.7 * (10**+308)
double 64 bits
1.7E-308 to 1.7E+308
3.36210 * (10**-4932) to 1.18973 * (10**+4932)
long double 96 bits
3.36210E-4932 to 1.18973E+4932

Data Types Rajalakshmi Engineering College 4


Points to Remember
 When an adjective (qualifier) short, long or unsigned is used with
a basic data type specifier, C compilers treat the data type as int.
 If we want to declare a character variable as unsigned, then we
must do so using both the terms unsigned char.

Data Types Rajalakshmi Engineering College 5


Integer Data Type
 Integers are whole numbers with a range supported by a
particular machine.
 They have no fractional parts.
 Integers are represented in C by int data type. An identifier
declared as int becomes an integer variable and can hold integer
values only.

Data Types Rajalakshmi Engineering College 6


Floating Point Data Type
 Floating point (or real) numbers are stored in 32 bits (on all 16 bit
and 32 bit machines) with 6 digits of precision.
 A number having fractional part is a called floating point number.
 For example, the number 12 is an integer, but 12.0 is a floating
point number.
 Floating point numbers can also be written in exponent form.
 An identifier declared as float data type becomes a floating point
variable and can hold floating point numbers only.

Data Types Rajalakshmi Engineering College 7


Double Precision Data Type
 When the accuracy provided by a float number is not sufficient,
the type double can be used to define the number.
 A double data type number uses 64 bits giving a precision of 14
digits.
 These are known as double precision numbers.
 To extend the precision further, use long double.

Data Types Rajalakshmi Engineering College 8


Character Data Type
 A single character can be defined as a character (char) type data.
 An identifier declared as char data type becomes a character
variable.
 Characters are usually stored in 1 byte (8 bits) of internal storage.
 The qualifiers signed or unsigned may be explicitly applied to char.
 A signed char is same as ordinary char and has range from -128 to
127, whereas unsigned char has a range from 0 to 255.

Data Types Rajalakshmi Engineering College 9


Thank You

You might also like