KEMBAR78
CPP Data Types Cheat Sheet | PDF
0% found this document useful (0 votes)
73 views2 pages

CPP Data Types Cheat Sheet

This cheat sheet provides an overview of C++ data types, including integer types (int, long, long long, short, unsigned), floating-point types (float, double, long double), character and text types (char, string, char[]), boolean type (bool), array and vector types, and advanced types (pair, tuple, struct). Each type is accompanied by a brief description and example usage. It serves as a quick reference for C++ programming.

Uploaded by

mathway319
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views2 pages

CPP Data Types Cheat Sheet

This cheat sheet provides an overview of C++ data types, including integer types (int, long, long long, short, unsigned), floating-point types (float, double, long double), character and text types (char, string, char[]), boolean type (bool), array and vector types, and advanced types (pair, tuple, struct). Each type is accompanied by a brief description and example usage. It serves as a quick reference for C++ programming.

Uploaded by

mathway319
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

C++ Data Types Cheat Sheet

1. Integer Types

int: 32-bit, -2B to 2B (e.g., int x = 10;)

long: At least 32-bit (e.g., long y = 100000;)

long long: 64-bit, for very large numbers (e.g., long long z = 1e18;)

short: 16-bit, smaller values (e.g., short s = 100;)

unsigned: Positive only (e.g., unsigned int u = 500;)

2. Floating-Point Types

float: 4 bytes, ~6 digits precision (e.g., float x = 3.14f;)

double: 8 bytes, ~15 digits precision (e.g., double y = 3.141592;)

long double: More precision (used rarely)

3. Character and Text

char: Single character (e.g., char c = 'A';)

string: Text (e.g., string name = "An";)

char[]: C-style string (lower-level)

4. Boolean (Logical)

bool: true or false (e.g., bool check = true;)

5. Array and Vector

int a[100]; // Fixed-size array

vector<int> v; // Dynamic array

v.push_back(5); // Add element

v.size(); // Get size

6. Advanced Types

pair<int, int> p = {1, 2};

tuple<int, string, double> t;


C++ Data Types Cheat Sheet

struct Student { string name; int age; };

You might also like