← All languages

C++ programs

From Hello World through STL-sized problems.

19 topics · 165 examples · ordered like a syllabus

Open Hello World

Topics, in order

Finish one. The next is the card below.

  1. 01Basic ProgramsBasic C++ programs for cout, cin, types, and simple math. First week, walked line by line.
    • Hello World
    • Display Your Name
    • User Input
    14 programs →
  2. 02Conditional ProgramsC++ if / else: even/odd, leap years, vowels. The equal-to case is the quiet bug.
    • Check for Even Odd
    • Largest Among 3
    • Vowel/Consonant Check
    4 programs →
  3. 03Loop ProgramsC++ for and while: tables, GCD, primes. Off-by-one prints one row too few.
    • Multiplication Table
    • Sum of n Natural Numbers
    • Factorial of a Number
    14 programs →
  4. 04Pattern ProgramsC++ nested loops and spaces. Count on paper first or the triangle leans.
    • Right Half Pyramid
    • Left Half Pyramid
    • Full Pyramid
    6 programs →
  5. 05Array ProgramsC++ arrays: max, average, 2D. Size is on you. Don't read past n.
    • Array Max & Min
    • Array Average
    • Merge Arrays
    4 programs →
  6. 06String Conversion ProgramsC++ stoi, stringstream, ch - '0'. stoi throws. atoi does not.
    • Convert Char to String
    • Convert Integer to Char
    • Convert String to Integer
    11 programs →
  7. 07Advanced Number ProgramsC++ bases, Armstrong, neon. Remainders come out backwards. Reverse them.
    • Check Strong Number
    • Calculate Power of a Number
    • Calculate Compound Interest
    13 programs →
  8. 08String Operations ProgramsC++ concat, reverse, palindrome. string is a class. char[] is a headache.
    • Copy Strings
    • Concatenate Two Strings
    • Reverse a String
    10 programs →
  9. 09Array Operations ProgramsC++ reverse, merge, transpose. Watch the second index.
    • Reverse an Array
    • Merge Two Sorted Arrays
    • Merge Two Arrays
    7 programs →
  10. 10Advanced Pattern ProgramsMore C++ star patterns. Same nested loops, more spaces.
    • Star Pattern
    • Triangle Pattern
    • Diamond Pattern
    6 programs →
  11. 11Application ProgramsC++ menus and calculators. Invalid choice is the branch people skip.
    • Menu Driven Program
    • Scientific Calculator
    • Convert String to Date
    3 programs →
  12. 12Sorting & Searching ProgramsC++ n log n vs n². Binary search needs sorted input.
    • Bubble Sort
    • Insertion Sort
    • Selection Sort
    13 programs →
  13. 13Object-Oriented ProgrammingC++ classes, inheritance, virtual. Forget virtual and the wrong function runs.
    • Class and Object Basics
    • Default Constructor
    • Parameterized Constructor
    18 programs →
  14. 14Memory Management ProgramsC++ new / delete, unique_ptr. Every new needs a delete, or don't use new.
    • Basic Pointers
    • Pointer Arithmetic
    • Pointer to Pointer
    11 programs →
  15. 15STL Containers ProgramsC++ vector, map, set. vector[i] does not bounds-check. at() does.
    • Vector Basics
    • Vector Operations
    • 2D Vector
    10 programs →
  16. 16File Handling ProgramsC++ ifstream and ofstream. Always check is_open().
    • Write to File
    • Read from File
    • Append to File
    6 programs →
  17. 17Exception Handling ProgramsC++ try / catch. throw objects, not integers. catch (...) last.
    • Basic try-catch
    • Multiple catch Blocks
    • Custom Exception Class
    5 programs →
  18. 18Recursion ProgramsC++ factorial, fibonacci, Hanoi. Missing base case is a stack overflow.
    • Factorial using Recursion
    • Fibonacci using Recursion
    • Tower of Hanoi
    5 programs →
  19. 19Bitwise Operations ProgramsC++ & | ^ <<. ^ is XOR, not power.
    • Basic Bitwise Operations
    • Check and Set Bits
    • Count Set Bits
    5 programs →