Tag: functions
All the articles with the tag "functions".
-
GCD and LCM in C++: The Euclidean Algorithm Explained
Find the GCD and LCM of two numbers in C++. Learn the Euclidean algorithm with loops and recursion, the LCM formula, and the built-in std::gcd in C++17.
-
How to Pass an Array to a Function in C++ (The Right Way)
Learn how to pass an array to a function in C++: pointer decay, why you must pass the length, modifying in place, and how a std::vector makes it safer.
-
C++ Pass Vector to Function: By Reference, Value, or Const
Learn how to pass a vector to a function in C++ by value, by reference, and by const reference. Understand copies vs references and which to use, with examples.
-
How to Return Multiple Values from a C++ Function: 5 Practical Methods
C++ functions return one value by default. Learn five clean ways to return multiple values: structs, pairs, tuples, output parameters, and std::tie.