C Programming Language Class 3 : C Data Types
Data types in any of the language means that what are the various
type of data the variables can have in that particular language.
Whenever a variable is declared it becomes necessary to define data type
that what will be the type of data that variable can hold.
Mainly there are two types of data types:
1. Primary Data Type
2. Secondary Data Type
Primary Data Type : character, integer, float, double, void
Secondary Data Type : arrays, pointer, structures, union, enum
C data types
C language also supports the wide range of data type like :
Data type |
Keyword |
Bits |
Range |
integer |
int |
16 |
-32768 to 32767 |
long integer |
long |
32 |
-4294967296 to 4294967295 |
short integer |
short |
8 |
-128 to 127 |
unsigned integer |
unsigned |
16 |
0 to 65535 |
character |
char |
8 |
0 to 255 |
floating point |
float |
32 |
approximately 6 digits of precision |
double floating point |
double |
64 |
approximately 12 digits of precision |
The data type can also be of signed & unsigned. If the unsigned
notation is used then the range becomes just double. The long, signed
& unsigned notations are also called qualities.
Sample Data types program :
Enum Data Type
This is an user defined data type having finite set of enumeration constants. The keyword ‘
enum‘ is used to create
enumerated data type.
Syntax:
enum [data_type] {const1, const2, …., const n};
Example Code:
enum mca(software, internet, seo); |
Typedef
It is used to create new data type. But it is commonly used to change existing data type with another name.
Syntax:
typedef [data_type] synonym;
OR
typedef [data_type] new_data_type;
Example Code:
Comments
Post a Comment