Data Types
Menu
Data Types
C++ has several built-in data types that you can use to define variables and constants in your programs. Here are some of the most common data types in C++:
- Integer types:
- int: a 32-bit signed integer.
- short: a 16-bit signed integer.
- long: a 32-bit or 64-bit signed integer.
- long long: a 64-bit signed integer.
- Floating-point types:
- float: a 32-bit floating-point number.
- double: a 64-bit floating-point number.
- long double: a larger floating-point number that can store more precision.
- Character types:
- char: a 8-bit character.
- wchar_t: a wide character, which can store characters from different character sets.
- char16_t: a 16-bit character.
- char32_t: a 32-bit character.
- Boolean type:
- bool: a boolean value that can be either true or false.
Example:
#include
#include
using namespace std;
int main() {
int num = 10;
float f = 3.14f;
double d = 3.14159265359;
bool is_true = true;
char c = 'A';
string name = "John Doe";
cout << "Integer: " <
Menu
Join To Get Our Newsletter