cpp-cheatsheet

C++ Quick Reference

The essential C++ syntax guide for Bits Bytes learners. Optimized for rapid mobile lookup.

Basic Program Structure [Tap to Toggle]

Every C++ program begins with these fundamental lines.

#include <iostream>
using namespace std;

int main() {
    cout << "Hello Bits Bytes!";
    return 0;
}
Essential Data Types [Tap to Toggle]
Type Example
intint age = 24;
floatfloat price = 19.99;
doubledouble pi = 3.14159;
charchar grade = 'A';
stringstring name = "User";
boolbool isReady = true;
Decision Making (If/Switch) [Tap to Toggle]

If-Else Structure

if (condition) {
    // code
} else if (other) {
    // code
} else {
    // code
}

Switch Statement

switch (expression) {
    case 'A': cout << "Excellent"; break;
    case 'B': cout << "Good"; break;
    default: cout << "Keep Learning";
}
Iteration (Loops) [Tap to Toggle]

For Loop

for (int i=0; i<5; i++) {
    cout << i;
}

While Loop

while (condition) {
    // code
}

Do-While Loop

do {
    // code
} while (condition);