GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing www.geeksforgeeks.org — Data Types in C++ - GeeksforGeeks Data Types in C++Last Updated : 10 Sep, 2026 Data types form the foundation of data representation in C++. Every variable must be associated with a data type that defines the kind of value it can store and how that value is handled by the compiler.
Classification of Data Types in C++Data types in C++ can be broadly classified into three categories: ![]() Integer Data Type (int)The int data type is used to store whole numbers.
Output 10 Explanation: The variable var stores the integer value 10. The keyword int specifies that the variable can hold integer values.
Let us explore how primitive data types are used in C++. Character Data Type (char)The char data type stores a single character enclosed in single quotes. Typically occupies 1 byte and stores the ASCII value of the character internally.
Output A Boolean Data Type (bool)The boolean data type is used to store logical values: true(1) or false(0). The keyword used to define a boolean variable is bool. Its typical size is 1 byte.
Output 1 Floating Point Data Type (float)Float is used to store decimal numbers. It is declared using the float keyword, typically occupies 4 bytes, and can store values approximately from 1.2e-38 to 3.4e+38.
Double Data Type (double)Double (double) is used to store decimal numbers with higher precision than float. It typically occupies 8 bytes and can store values approximately from 1.7e-308 to 1.7e+308.
Void Data Type (void)The void data type represents the absence of value. We cannot create a variable of void type. It is used for pointer and functions that do not return any value using the keyword void.
Derived Data Types in C++Derived data types are formed using fundamental data types.
User Defined Data TypesUser-defined data types allow programmers to create their own data structures.
Standard Library TypesThe C++ Standard Library provides many useful types that are implemented as classes or templates.
These are not fundamental data types. They are types provided by the C++ Standard Library. For example:
Size of Data Types in C++The exact size of a data type depends on the compiler and platform.
The sizeof operator can be used to determine the actual size on a system.
Data Type ModifiersC++ provides type modifiers that can alter the size, range, or representation of certain fundamental data types. The commonly used modifiers are short, long, signed, and unsigned.
Example
Rules for Type Modifiers
Comment ExploreStandard Template Library(STL) Practice & Problems | ||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |