/    /  CPP – Data types

Data types

 

In C++ a data type specifies what type of value may be assigned with an identifier. Data types can be grouped under three types:-

  1. a) Basic data type or built-in data type:- This data type provided by the compiler can be used to declare an identifier as constant or variable. There are 5 types of basic data types:-
    1. i) int:- This data type is used to assign a value without fraction. It needs 2 bytes of storage space. Short int, signed int, unsigned int, long int is also part of the integer used for a different purpose. Its range is -32768 to 32767.
    2. ii) float:- This data type is used to assign a floating value written with or without exponents. It needs 8 bytes of storage space. Its range is 1.7E-308 to 1.7E308. Its range can be extended by using a long double datatype.
    3. iii) char:- This datatype deals with a single character enclosed in single quotes. It uses 1 byte of memory space.
    4. iv) void:- It represents no value i.e. an empty set. It is mainly used within functions to indicate that these functions return no value.
  2. b) Derived data type:- This type of data type can be derived from basic datatypes. Example: array, pointers, references.
  3. c) User-defined data type:- This type may be obtained by grouping linked data together.