C++ Data 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++ is mainly divided into three types:
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: char, int, bool, float, etc. Primitive data types available in C++ are:
-Integer
-Character
-Boolean
-Double Floating point
-Floating Point
-Wide Character
-Valueless or Void
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:
-Array
-Pointer
-Function
-Reference
Abstract or User-Defined Data Types: These data types are defined by the user itself. Like, defining a class in C++ or a structure. C++ provides the following user-defined datatypes:
-Structure
-Enumeration
-Class
-Union
-Type of defined Datatypes
This article discusses primitive data types available in C++
-Character: The character data type is used for storing characters. The keyword used for the character data type is char. Characters typically require 1 byte of memory space and range 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. The keyword used for the floating-point data type is float. Float variables typically require 4 byte of memory space.
-void: Void means without any value. void data type represents a valueless entity. A void data type is used for those function which does not return a value.
-Integer: The keyword used for integer data types is int. Integers typically require 4 bytes of memory space and range from -2147483648 to 2147483647.
-Boolean: The boolean data type is used for storing boolean or logical values. A boolean variable can store either true or false. The keyword used for the boolean data type is bool.
-Double Floating Point: Double Floating Point data type is used for storing double-precision floating-point values or decimal values. The keyword used for double floating-point data type is double. Double variables typically require 8 bytes of memory space.
Please Watching My Video is Below
div class='clearfix'/>