To calculate the magnitude (or length) of a 2D vector with components (x, y), you can use the following formula: Magnitude = sqrt(x^2 + y^2) C++ provides the sqrt() function in the header for calculating square roots.