C++ Code Reorder Medium +20 XP
Lambda Capture
Arrange a lambda that captures and modifies a variable.
Click lines in the correct order
Available lines4 left
Your order
Click lines above to build your solution.
Show answer and explanation
Answer: int x = 10;
auto addFive = [&x]() { x += 5; };
addFive();
cout << x;
Declare x, create lambda capturing x by reference, call it, then print the modified x.
Hint: Declare before capturing, call before printing.
What this challenge tests
Code Reorder in C++: lambdas, capture.