Level 1: Introduction to C++

What is it? C++ is a powerful, high-performance programming language that adds Object-Oriented features to the C language.

Features:

Try This 🔥

Did you know? Unreal Engine, a leading game development engine, is built primarily on C++.

✅ You learned this concept!

Level 2: Basic Program Structure

What is it? A simple C++ program structure with basic input/output functionality using the standard library.


#include <iostream>
using namespace std;

int main()
{
    cout << "Hello World";
    return 0;
}

Explanation:

Try This 🔥

Change "Hello World" to your own name and run the code in the compiler.

Try in Compiler ▶

✅ You wrote your first C++ program!

Level 3: Variables & Data Types

What is it? Variables are used to store data in memory. You must declare the data type before using a variable.


int age = 18;
float pi = 3.14f;
char grade = 'A';
string name = "Rajan";

cout << age << " " << name;

Explanation: int stores whole numbers. float stores decimals. char stores single characters.

Try This 🔥

Create variables for your graduation year and your target percentage.

Try in Compiler ▶

✅ You learned this concept!

Level 4: Operators

What is it? Symbols used to perform arithmetic or logic on variables.


int x = 10;
int y = 5;

int result = x + y;
cout << result;

Explanation: C++ supports standard math operators like +, -, *, /, and % (modulo/remainder).

Try This 🔥

Modify the code to calculate (10 + 5) * 2 and print the result.

Try in Compiler ▶

✅ You learned this concept!

Level 5: Conditionals

What is it? Logic that allows the program to make decisions based on specific conditions.


int x = 10;

if (x > 0)
{
    cout << "Positive";
}
else
{
    cout << "Negative or Zero";
}

Try This 🔥

Add an else if block to explicitly check if x == 0.

Try in Compiler ▶

✅ You learned this concept!

Level 6: Loops

What is it? Loops execute a block of code repeatedly as long as a condition remains true.


for (int i = 0; i < 5; i++)
{
    cout << i << endl;
}

Explanation: A for loop is ideal when you know exactly how many times you want to iterate.

Try This 🔥

Change the loop to count from 10 down to 1.

Try in Compiler ▶

✅ You learned this concept!

Level 7: Functions & Overloading

What is it? Functions isolate reusable logic. Overloading allows multiple functions to share the same name with different parameters.


int add(int a, int b) {
    return a + b;
}

float add(float a, float b) {
    return a + b;
}

Try This 🔥

Write a main() function to call your add functions with integers and floats to test them.

Try in Compiler ▶

✅ You learned this concept!

Level 8: Arrays & Strings

What is it? Arrays hold multiple values of the same type. Strings hold text (arrays of characters).


int arr[3] = {1, 2, 3};

for (int i = 0; i < 3; i++)
{
    cout << arr[i];
}

Explanation: You can access array elements using their index, starting from 0. In C++, you can also use #include <string> for advanced string manipulation.

Try This 🔥

Create a string variable with your name and print its length using name.length().

Try in Compiler ▶

✅ You learned this concept!

Level 9: Object-Oriented Programming (OOP)

What is OOP? Programming using objects and classes to model real-world behavior.

Try This 🔥

Think of real-world objects (like a Bank Account) and list what properties (data) and actions (methods) it would have.

✅ You learned this concept!

Level 10: Classes & Objects

What is it? A Class is a blueprint. An Object is an instance of that class.


class Car
{
public:
    string brand;
    void show()
    {
        cout << brand;
    }
};

int main()
{
    Car c1;
    c1.brand = "BMW";
    c1.show();
    return 0;
}

Try This 🔥

Create a second Car object named c2 and give it the brand "Audi". Call c2.show().

Try in Compiler ▶

✅ You learned this concept!

Level 11: Constructors & Destructors

What is it? Special functions that run automatically when an object is created (Constructor) or destroyed (Destructor).


class Car
{
public:
    Car()
    {
        cout << "Created";
    }
    ~Car()
    {
        cout << "Destroyed";
    }
};

Explanation: The Constructor shares the exact same name as the class. The Destructor also shares the name, but has a tilde ~ in front.

Try This 🔥

Instantiate an object of Car inside main() and watch both messages print automatically.

Try in Compiler ▶

✅ You learned this concept!

Level 12: STL (Vectors)

What is it? The Standard Template Library (STL) provides powerful pre-built data structures. Vectors are dynamic arrays.


#include <vector>
#include <iostream>
using namespace std;

int main()
{
    vector<int> v;
    v.push_back(10);
    cout << v[0];
    return 0;
}

Explanation: A vector is like an array, but it can automatically shrink and grow in size. push_back adds an element to the end.

Try This 🔥

Add 5 elements to a vector using a loop, then print them all out.

Try in Compiler ▶

✅ You learned this concept!

Level 13: Exception Handling

What is it? Safely managing runtime errors so the program doesn't crash abruptly.


try
{
    int age = 15;
    if (age < 18)
    {
        throw "Access Denied";
    }
}
catch (const char* msg)
{
    cout << msg;
}

Try This 🔥

Change age to 20 and see that the error is no longer thrown.

Try in Compiler ▶

✅ You learned this concept!

Level 14: Practical Programs

What is it? Bringing concepts together to build real logic scripts.

1. Sum of Array Elements


int arr[3] = {10, 20, 30};
int sum = 0;

for (int i = 0; i < 3; i++)
{
    sum = sum + arr[i];
}

cout << sum;

Try This 🔥

Combine these logic snippets inside a main() function to run them completely.

Try in Compiler ▶

✅ You learned this concept!

Academic SRM Resources Available

Access SRM Resources 📚

Ready to master C++?

Start C++ Quiz 🚀