#C7838. Create a Closure Adder
Create a Closure Adder
Create a Closure Adder
In this problem, you are required to implement a function that creates a closure for adding numbers. Specifically, given an integer (x), you need to implement a function, called create_adder
, which returns another function (or lambda) that takes an integer (y) as input and returns the sum (x + y). This is a classic example of using closures to capture an environment variable. In the contest version, your program should read input from STDIN and output the results to STDOUT.
The input format is as follows: The first line contains an integer (T) indicating the number of test cases. Each of the following (T) lines contains two space-separated integers (x) and (y). For each test case, you should create an adder from (x) and then compute the result of adding (y) using this adder. Your program should print the result for each test case on a new line.
inputFormat
The first line of input contains an integer (T) representing the number of test cases. Each subsequent line contains two integers (x) and (y) separated by a space.
outputFormat
For each test case, output a single line containing the result of (x + y) computed using a closure created by create_adder
.## sample
2
5 2
5 10
7
15
</p>