CJCoding With Joseph
15free / daySign inCreate account

Lambda with a Capture

Lambdas can capture variables from the surrounding scope. Complete addTax(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 example addTax(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
Topics:
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.