noknow.dev
Sign inSign up
Course overview
C++ Fundamentals
0 / 39 lessons0%

Getting Started

  • Hello, World!
  • Variables and Data Types
  • Arithmetic and Operators
  • Working with std::string
  • Type Conversion and Casting

Control Flow

  • if / else if / else
  • switch / case
  • while and do-while Loops
  • for Loops
  • break, continue, and Finding Primes

Functions

  • Writing Functions
  • Pass by Value vs. Pass by Reference
  • Overloading and Default Parameters
  • Recursion

Arrays and Strings

  • C-style Arrays
  • std::vector — Dynamic Arrays
  • std::string Deep Dive
  • 2D Arrays and Matrices

Pointers and Memory

  • Memory Addresses and Pointers
  • Dynamic Memory: new and delete
  • References vs Pointers

Object-Oriented Programming

  • Classes and Objects
  • Constructors and Destructors
  • Inheritance
  • Virtual Functions and Polymorphism
  • Operator Overloading

The Standard Template Library

  • std::vector in Depth
  • std::map and std::unordered_map
  • std::set and Sorted Unique Collections
  • STL Algorithms

Templates and Generic Programming

  • Function Templates
  • Class Templates

Modern C++ (C++11/14/17)

  • auto and Range-based for
  • Lambda Functions
  • Smart Pointers
  • Move Semantics

Error Handling and Exceptions

  • try / catch / throw
  • Custom Exception Classes
  • RAII and Resource Management

Type Conversion and Casting

0m 00s

Converting Between Types

int    a = 7;
double b = a;   // implicit: int -> double (safe)

double x = 3.99;
int    y = (int)x;              // C-style: 3 (truncates, not rounds)
int    z = static_cast<int>(x); // C++ style — preferred

static_cast — avoid integer division

int votes = 7, total = 10;
// Wrong: 7 / 10 = 0  (integer division)
double pct = static_cast<double>(votes) / total * 100;
// pct == 70.0

char and int are interchangeable

char c = 'A';
int  n = c;          // 65 (ASCII)
cout << (char)(c+1); // 'B'

Your Task

Write percentage(int part, int total) returning (part/total)*100 as a double.
Example: percentage(3, 4) → 75.0

Back
cppCtrl+Enter to run
Output

Click "Run" to execute your code.