Data Type in C | Types of data types

Data Type in C

Data Type: C language is reach in its data type. Data type are use to present the type of the value that can be represented by variable. They also specify the memory size required for the data value.
Data type is refer for computer memory representations for store value depending upon data structure in this is structure they occupied memory size in bytes in that storage they stored value in specific range.
C language having a large set of data type are classifies as follows:

  1. Primary\Fundamental\Basic\predefined\primitive\ data type
  2. User defined data type(Non-Primitive)
  3. Derived data type
  4. Empty data type


Data Type in C | Types of data types

Basic Data Type

Basic Data Type: The primary data type storage representation and machine instruction to handle constant differ from machine to machine. C compiler Supports Four basic data type namely char, int, float, double.

Integer Type: Integers are whole number with a machine dependent range of values. Following table shows that the data-type, its size and range of values.





Data-type
Size
Range
int / signed int
2 bytes
-32768 to 32767
unsigned int
2 bytes
0 to 65535
short int / signed
short int
1 byte
-128 to 127
unsigned short int
1 byte
0 to 255
long int / signed
long int
4 byte
-2147483648 to 2147483647
unsigned long int
4 byte
0 to 4294967295
Floating Point Type: Floating point number represents real numbers. Following are the types of floating point number its size and range.



Data-type
Size
Range
Float
4 bytes
3.4 e-38 to 3.4 e+38
Double
8 bytes
1.7 e-308 to 1.7 e+308
Long double
10 bytes
3.4 e-4932 to 1.1 e+4932
Character Type: A single character can be defined as a character type of data. Character are usually stored in 8 bits of internal storage. The following table shows range of values.



Data-type
Size
Range
char / signed char
1 bytes
-128 to 127
unsigned char
1 bytes
0 to 255



User-defined Data Types

User-defined Data Type: It is a user-defined data type, which holds its own data members and member functions, which can be accessed and used by creating an instance of that class. A class is like a blueprint for an object. Structure: A structure is a user defined data type in C/C+

Typedef (Type of definition): C supports a features known as type definition, that allows user to define as identifier that put on existing data-type. User-defined data-type identifier can use for later. Following is the syntax for creating user-defined data-type.
                   Syntax:-
typedef data_type identifier ;
Here data-type refers to an existing data-type and identifier refers to a new name given to the existing data-type. The data-type cannot create a new data-type a permanent use but we can use inside the program where it is defined.
e.g
       typedef unsigned long int INT ;
                    INT a;
       typedef double real ;
                    real x,y,z
Enum(Enumeration): The identifier is user-defined data-type and enumerated we can used to declare variable that can have one of the value enclosed within the braces known as enumerated (List of values). Following syntax for creating enum data-type.
                    Syntax:-
enum identifier {value1, value2,.....,value n}
In the above syntax identifier is a name that is for user defined data-type enum for enumeration (List of values) that any one value will stored on a variable of type identifier i.e enum.
e.g
       enum weekdays{sun, Mon, Tue, Wed, Thu, Fri, Sat} 

Post a Comment

Previous Post Next Post