Data types in C

Data type
            Data type defined which type of data or set of values are assigned in a variable.
We know that computer program manipulates various types of data. The type of each data value is identified at the beginning of the program design. The values or data used in a program may be of different types.
All variables use data-type during declaration to restrict the type of data to be stored. Therefore, we can say that data types are used to tell the variables the type of data it can store. Whenever a variable is defined in C, the compiler allocates some memory for that variable based on the data-type with which it is declared. Every data type requires a different amount of memory.
Data types in C are mainly divided into three types:
1.    Primitive Data Types:
 These data types are built-in or predefined data types and can be used directly by the user to declare variables. Example: int, char, float, bool etc. Primitive data types available in C are:
·      Integer
·      Character
·      Floating Point
·      Double Floating Point
·       Character
2.    Derived Data Types:
 The data-types that are derived from the primitive or built-in datatypes are referred to as Derived Data Types. These can be of four types namely:
·      Function
·      Array
·      Pointer
·      Reference
This article discusses primitive data types available in C.
·       Integer: Keyword used for integer data types is int. Integers typically requires 4 bytes of memory space and ranges from -2147483648 to 2147483647.
·       Character: Character data type is used for storing characters. Keyword used for character data type is char. Characters typically requires 1 byte of memory space and ranges from -128 to 127 or 0 to 255.
·       Floating Point: Floating Point data type is used for storing single precision floating point values or decimal values. Keyword used for floating point data type is float. Float variables typically requires 4 byte of memory space.
·       Double Floating Point: Double Floating Point data type is used for storing double precision floating point values or decimal values. Keyword used for double floating point data type is double. Double variables typically requires 8 byte of memory space.
Datatype Modifiers: As the name implies, datatype modifiers are used with the built-in data types to modify the length of data that a particular data type can hold. Data type modifiers available in C are:
·       Signed
·       Unsigned
·       Short
·       Long


Comments

Popular Posts