← All languages
C++ programs
From Hello World through STL-sized problems.
19 topics · 165 examples · ordered like a syllabus
Open Hello WorldTopics, in order
Finish one. The next is the card below.
- 01Basic ProgramsBasic C++ programs for cout, cin, types, and simple math. First week, walked line by line.
- Hello World
- Display Your Name
- User Input
- 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
- 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
- 04Pattern ProgramsC++ nested loops and spaces. Count on paper first or the triangle leans.
- Right Half Pyramid
- Left Half Pyramid
- Full Pyramid
- 05Array ProgramsC++ arrays: max, average, 2D. Size is on you. Don't read past n.
- Array Max & Min
- Array Average
- Merge Arrays
- 06String Conversion ProgramsC++ stoi, stringstream, ch - '0'. stoi throws. atoi does not.
- Convert Char to String
- Convert Integer to Char
- Convert String to Integer
- 07Advanced Number ProgramsC++ bases, Armstrong, neon. Remainders come out backwards. Reverse them.
- Check Strong Number
- Calculate Power of a Number
- Calculate Compound Interest
- 08String Operations ProgramsC++ concat, reverse, palindrome. string is a class. char[] is a headache.
- Copy Strings
- Concatenate Two Strings
- Reverse a String
- 09Array Operations ProgramsC++ reverse, merge, transpose. Watch the second index.
- Reverse an Array
- Merge Two Sorted Arrays
- Merge Two Arrays
- 10Advanced Pattern ProgramsMore C++ star patterns. Same nested loops, more spaces.
- Star Pattern
- Triangle Pattern
- Diamond Pattern
- 11Application ProgramsC++ menus and calculators. Invalid choice is the branch people skip.
- Menu Driven Program
- Scientific Calculator
- Convert String to Date
- 12Sorting & Searching ProgramsC++ n log n vs n². Binary search needs sorted input.
- Bubble Sort
- Insertion Sort
- Selection Sort
- 13Object-Oriented ProgrammingC++ classes, inheritance, virtual. Forget virtual and the wrong function runs.
- Class and Object Basics
- Default Constructor
- Parameterized Constructor
- 14Memory Management ProgramsC++ new / delete, unique_ptr. Every new needs a delete, or don't use new.
- Basic Pointers
- Pointer Arithmetic
- Pointer to Pointer
- 15STL Containers ProgramsC++ vector, map, set. vector[i] does not bounds-check. at() does.
- Vector Basics
- Vector Operations
- 2D Vector
- 16File Handling ProgramsC++ ifstream and ofstream. Always check is_open().
- Write to File
- Read from File
- Append to File
- 17Exception Handling ProgramsC++ try / catch. throw objects, not integers. catch (...) last.
- Basic try-catch
- Multiple catch Blocks
- Custom Exception Class
- 18Recursion ProgramsC++ factorial, fibonacci, Hanoi. Missing base case is a stack overflow.
- Factorial using Recursion
- Fibonacci using Recursion
- Tower of Hanoi
- 19Bitwise Operations ProgramsC++ & | ^ <<. ^ is XOR, not power.
- Basic Bitwise Operations
- Check and Set Bits
- Count Set Bits