Lesson 4

Operators and Expressions

Operators allow you to perform calculations and comparisons. They are a core part of almost every C++ program.

Example

Example
#include <iostream>
using namespace std;

int main()
{
    int a = 10;
    int b = 3;

    cout << "a + b = " << a + b << endl;
    cout << "a - b = " << a - b << endl;
    cout << "a * b = " << a * b << endl;
    cout << "a / b = " << a / b << endl;
    cout << "a % b = " << a % b << endl;
    return 0;
}
Book Tip:

This short lesson is part of a larger learning path. The full book expands each topic with more explanation, exercises, and projects.