Professional Documents
Culture Documents
A data type in C programming language declares the type of data that a variable
can store and how much memory is required to store this data.
Character (char)
Integer (int)
Floating Point (float)
Double Floating Point (double)
All other data types are derived from these basic data types.
The size of basic data types are machine dependent, For example size of an integer
data type in a 32 bit computer is 4 bytes whereas size of integer data type in 16 bit
computer is 2 bytes. To know the exact size of any data type, we should
use sizeof operator.
Integer data type is used to store a value of numeric type. Memory size of a variable of
integer data type is dependent on Operating System, For example size of an integer
data type in a 32 bit computer is 4 bytes whereas size of integer data type in 16 bit
computer is 2 bytes.
Keyword int is used to declare variables of type integer. Range of integer(int) data
type in 16 Bit system is -32,768 to 32,767.
For Example
int i = 2015;
Above statement declares a variable 'i' of integer data type and stores 2015 in it's
memory location.
For example : A variable of int type requires 2 bytes (= 2 x 8 = 16 bits). Out of this,
1 bit is reserved for sign (-or+) and remaining 15 bits can contain 0 or 1. So the range
of values supported will be -215 (-32768) to +215-1 (+32767).
The following table, shows the different basic data types, their size and value range in
a 16 bit operating system.
Character data type is used to store a character. A variable of character data type
allocated only one byte of memory and can store only one character. Keyword char is
used to declare variables of type character. Range of character(char) data type is -128
to 127.
For Example
char c = 'A';
Above statement declares a variable 'c' of character data type and stores character 'A'
in it's memory location.
Floating point data type can be sub-divided into two types on the basis of precision
and size.
Floating point data type in C is used to store a value of decimal values. Memory size
of a variable of floating point data type is dependent on Operating System, For
example size of an floating point data type in a 16 bit computer is 4 bytes. Keyword
float is used to declare variables of floating point type. Floating point data type
provides up-to 6 digits of precision.
For Example
float f = 11.243567;
Above statement declares a variable 'f' of float data type and stores 11.243567 in it's
memory location.
For Example
double d = 11676.2435676542;
Above statement declares a variable 'd' of double data type and stores
11676.2435676542 in it's memory location.
All C compilers support four fundamental data types
char -128 to 127 a single byte(8 bits) and can store one character type
(Characters) data