Data types

Data types are means to identify the type of data and associated operations of handling it. When a variable is declared of particular type then the variable becomes a place where the data is stored and data type is the type of value stored in that variable. C data types can be classified as:
  1.  Fundamental data types
  2. Derived data types
  3. User-defined data types(enumeration)
Types
Data Types
Basic data typesint, char, float, double
Enumeration data typeenum
Derived data typepointer, array, structure, union
Void data typevoid

Fundamental Data Types

  • Integer: These variables can take positive and negative integer values by default.
          1. int: int type cannot hold any fraction or decimal value. It takes 2 bytes in Turbo C 3.0 and 4  bytes in Dev C++ compiler.
          2. short int: In Turbo C 3.0 and Dev C++, short int and int refer to same thing. Its range is -32768 to +32767.
          3. long int: It takes 4 bytes to store. Its range is -2147483648 to +2147483647.
          4. unsigned short: No negative values can be stored. So the range is from 0 to +65535.
          5. unsigned int: Same as unsigned short.
         6. unsigned long int or unsigned long: No negative number can be stored. So its range is 0 to +4294967295.
          7. char: Capable of storing one character. A char value takes 1 byte of memory.
          8. unsigned char: Its range is 0 to 255. Actually all ASCII values are unsigned.
  •  Floating Point/ Real Types
         1. float: A float takes 4 bytes of storage. The value can be positive or negative.
         2. double: A double takes 8 bytes of storage. This value can be positive or negative.

Derived data types

Derived data types are those data types which are derived from the existing fundamental data types, example pointers,array,structure,union.All these are the combinations of the above described data  types .All theses derived data types will be discussed in detail in later sections.

User defined data types

User defined data types are those which are which are defined by the user .Any real world object can be made as a datatype such as colours u can assign a value to color using enum. Except enum 'typedef' keyword can also be used to create the user defined data types.These data types provide the ease to understand the program such as if the color of light is red you stop your car at traffic signals ,but on green you move on .For a computer program to understand we create the user defined type named colors and then use the variables .

How ,when ,where and why to use the particular data type will be cleared to you when you try to implement certain logics via programming and stay tuned to the upcoming blog updates. 

0 comments:

Post a Comment