Thursday, 11 August 2016

Data Types of C



Classification Of data types

  • C has five Basic data types -
  1. Character - keyword used is char.
  2. Integer - keyword used is int.
  3. Floating Point - keyword used is float.
  4. Double precision floating point - keyword used is double.
  5. Void - keyword used is void.
  • C has four type qualifiers also known as type modifiers. They precede the basic data types.
  1. short
  2. long
  3. signed
  4. unsigned
  • A type modifier alters the meaning of the base data type to yeild a new type. The following points should be noted.
  1. Each of these modifiers can be applied to the base type int .
  2. The modifiers signed and unsigned can also be applied to the base type char.
  3. In addition long can be applied to double.
  4. When the base type is omitted from a declaration, int is assumed.
  • A complete list of possible data types is mentioned below.
  1. bool
  2. char
  3. unsigned char
  4. signed char
  5. int
  6. unsigned int
  7. signed int
  8. short int
  9. unsigned short int
  10. long int
  11. unsigned long int
  12. signed long int
  13. float
  14. double
  15. long double

  • Then there are three types of Derived data types -
    1. Array
      • It is a collection of similar type of data (or data types) stored in contiguous memory location
    2. Function
      • A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions.
    3. Pointer
      • A pointer is a variable which contains the address in memory of another variable. We can have a pointer to any variable type.

  • Then there are also three types of User-defined data types -
    1. Union
      • A union is a special data type available in C that allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Unions provide an efficient way of using the same memory location for multiple-purpose.
    2. Structure
      • A structure in the C programming language is a complex data type declaration that defines a physically grouped list of variables to be placed under one name in a block of memory, allowing the different variables to be accessed via a single pointer or variable of type struct. "Class" is c++ is an advanced version of structure.
    3. Enumeration
      • Enumerated Types allow us to create our own symbolic names for a list of related ideas. The keyword for an enumerated type is enum.


2 comments:

  1. Vishal & Jeevan u hv mentioned da data types in c. I think da data types sd b classified as fundamental,derived & user defined.den da data types u hv mentioned sd fall under those categories.

    ReplyDelete
    Replies
    1. Yeah. Actually it is written that "C has five 'basic' data types". I forgot to mention about the three types of derived and user defined data types.

      Delete

If u need any help,