Back to Modules

C++ Tutorial

Master C++ programming with our comprehensive tutorial. Learn through examples and hands-on practice.

Full Playlist (Watch on Youtube)

Introduction to C++

C++ is a powerful general-purpose programming language that extends C with object-oriented features.

Examples:

#include <iostream>
using namespace std;

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

A simple Hello World program in C++

Basic C++ Syntax

Learn the fundamental syntax and structure of C++ programs including variables, data types, and operators.

Examples:

int number = 42;
double pi = 3.14159;
char grade = 'A';
bool isValid = true;
string name = "John";

Common data types and variable declarations

// Arithmetic operators
int sum = a + b;
int difference = a - b;
int product = a * b;
int quotient = a / b;
int remainder = a % b;

Basic arithmetic operators in C++

Control Structures

Control structures allow you to control the flow of program execution.

Examples:

// If-else statement
if (score >= 90) {
    cout << "Grade A";
} else if (score >= 80) {
    cout << "Grade B";
} else {
    cout << "Grade C";
}

// For loop
for (int i = 0; i < 5; i++) {
    cout << i << " ";
}

// While loop
while (condition) {
    // code block
}

Common control structures in C++