Data types
In C, each
variable must be declared before it is used. When a variable is declared, a
type is assigned to it. During compilation, memory is reserved for each
variable. The amount of memory that is reserved depends on the stated type.
The memory
requirements for each data type will determine the permissible range of values
for that data type.
Data Types Memory
Req Range
1. char
(signed) 1 byte -128 to 127
Unsigned char 1 byte 0 to 255
2. int 2
bytes
Signed int 2
bytes -32768
to 32767
Unsigned int 2 bytes 0 to 65535
Long int 4
bytes 0
to 2 32-1
3. float 4
bytes -3.4e-38
to 3.4e38
4. double 8
bytes 1.7e-308
to 1.7e308
Format
Specifier
c data item in a single character
d data item in an integer
e data item in a floating point value in
exponent form
f data item in floating point value
g data item is a floating point value
without trialing zeros
h data item is a short integer
i data item is a signed integer
ld data item is a long integer
o data item is an octal integer
x data item is a hexadecimal integer
s data item is a string
u data item is unsigned integer
# modifying
the basic data types
The basic
types may have various modifiers preceding them. The list of modifiers are:
1.
signed
2.
unsigned
3.
short
4.
long
Signed,
unsigned, short, lone can be used with int.
Signed,
unsigned can be used with char
Long can be
used with double.
The amount of
storage allocated is not fixed. ANSI has the following rules.
Short int
<= int <= long int
Float <=
double <= long double
Data types No. of Bytes
1. int 4 -2147483648
to 2147483647 %d
2. char 1 0
to 255 %c
3. float 4 -3.4e38 to
3.4e38 %f
4. double 8 -1.7e308 to 1.7e308
%lf or %e
0 Comments
Please Don't Post Spam Links Under Comment Section.