Data Types : ANSI C provides three types of data types which are as
void, int, char, double and float.
Array, References, and Pointers.
Structure, Union, and Enumeration.
|
Type |
Size (bytes) |
Format Specifier |
|
int |
at least 2, usually 4 |
%d |
|
char |
1 |
%c |
|
float |
4 |
%f |
|
double |
8 |
%lf |
|
short int |
2 usually |
%hd |
|
unsigned int |
at least 2, usually 4 |
%u |
|
long int |
at least 4, usually 8 |
%li |
|
long long int |
at least 8 |
%lli |
|
unsigned long int |
at least 4 |
%lu |
|
unsigned long long int |
at least 8 |
%llu |
|
signed char |
1 |
%c |
|
unsigned char |
1 |
%c |
|
long double |
at least 10, usually 12 or 16 |
%Lf |
|
Type |
Storage
size |
Value
range |
|
char |
1
byte |
-128
to 127 or 0 to 255 |
|
unsigned
char |
1
byte |
0
to 255 |
|
signed
char |
1
byte |
-128
to 127 |
|
int |
2
or 4 bytes |
-32,768
to 32,767 or -2,147,483,648 to 2,147,483,647 |
|
unsigned
int |
2
or 4 bytes |
0
to 65,535 or 0 to 4,294,967,295 |
|
short |
2
bytes |
-32,768
to 32,767 |
|
unsigned
short |
2
bytes |
0
to 65,535 |
|
long |
8
bytes |
-9223372036854775808
to 9223372036854775807 |
|
unsigned
long |
8
bytes |
0
to 18446744073709551615 |
|
Type |
Storage size |
Value range |
Precision |
|
float |
4 byte |
1.2E-38 to 3.4E+38 |
6 decimal places |
|
double |
8 byte |
2.3E-308 to 1.7E+308 |
15 decimal places |
|
long double |
10 byte |
3.4E-4932 to 1.1E+4932 |
19 decimal places |
The void Type : The void type specifies that no value is available. It is used in three kinds of situations.
|
S.No. |
Types
& Description |
|
1 |
Function returns as void : There are various functions in C which do not return any value or you can say they return void. A function with no return value has the return type as void. For example : void exit (int
status); |
|
2 |
Function arguments as void : There are various functions in C which do not accept any parameter. A function with no parameter can accept a void. For example : int rand(void); |
|
3 |
Pointers to void : A pointer of type void * represents the address of an object, but not its type. For example, a memory allocation
function void *malloc(size ); returns a pointer to void which can be casted to any
data type. |
|
Data Type |
Description |
|
Arrays |
Arrays are sequences of
data items having homogeneous values. They have adjacent memory locations to
store values. |
|
References |
Function pointers allow
referencing functions with a particular signature. |
|
Pointers |
These are powerful C
features which are used to access the memory and deal with their addresses. |
|
DataType |
Description |
|
Structure |
It is a package of variables of different types under a single
name. This is done to handle data efficiently. "struct" keyword
is used to define a structure. |
|
Union |
These allow storing various data types in the same memory
location. We can define a union with different members, but only a single
member can contain a value at a given time. It is used for save memory."union" keyword
is used to define a union. |
|
Enum |
Enumeration is a special data type that consists of integral
constants, and each of them is assigned with a specific name. "enum" keyword
is used to define the enumerated data type. |
No comments:
Post a Comment