REFERENCE C++

#include <iostream>

// Function declaration
void swap(int& a, int& b);

int main() {
    // Variable declaration and initialization
    int num1 = 5, num2 = 10;

    // Displaying the original values
    std::cout << "Before swapping: num1 = " << num1 << ", num2 = " << num2 << std::endl;

    // Calling the swap function
    swap(num1, num2);

    // Displaying the swapped values
    std::cout << "After swapping: num1 = " << num1 << ", num2 = " << num2 << std::endl;

    return 0;
}

// Function definition
void swap(int& a, int& b) {
    // Swapping the values using a temporary variable
    int temp = a;
    a = b;
    b = temp;
}