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 |
|---|---|
| int | int age = 24; |
| float | float price = 19.99; |
| double | double pi = 3.14159; |
| char | char grade = 'A'; |
| string | string name = "User"; |
| bool | bool 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);