← Back to Lambda Functions
Question 192
Lambda with a Capture
Lambda with a Capture
Lambdas can capture variables from the surrounding scope. CompleteaddTax(int price, int taxPercent)so it defines a lambda that CAPTURES taxPercent and adds that percentage of tax to a given price, then return the lambda applied to price. For exampleaddTax(100, 8)returns 108. Do NOT write a main function.
Expected Output:
108 60
= newline. The output ends with a newline — print one after the last line.
Hints2 available
Sign in to use hintsTopics:
Lambda Functions
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.