R.6 — Cheat sheet
Read one box at a time. No rush.
Program shape#
C++▶ Run
#include <iostream> int main(){ // your code here return 0;}Variables#
C++
int whole { 42 };double decimal { 3.14 };bool flag { true };char letter { 'A' };std::string text { "hello" };const int fixedValue { 10 };Choices#
C++
if (x > 0){}else if (x < 0){}else{}Loops#
C++
for (int i { 0 }; i < 10; ++i) { }while (condition) { }for (const auto& item : list) { }Functions#
C++
int add(int a, int b){ return a + b;}Lists and maps#
C++
std::vector<int> nums { 1, 2, 3 };nums.push_back(4); std::map<std::string, int> ages { { "Ana", 12 } };ages["Ben"] = 15;Structs and classes#
C++
struct Point{ double x {}; double y {};}; class Counter{public: void add() { ++m_n; } int get() const { return m_n; }private: int m_n { 0 };};Operators at a glance#
| Kind | Operators |
|---|---|
| math | + - * / % |
| shortcuts | += -= *= /= ++ -- |
| compare | == != < > <= >= |
| logic | && || ! |
Tip: press ← / → to move between lessons, / to search.