**Objective: -** Given a binary tree and X, Print all the paths starting from root so that sum of all the nodes in path equals to a given number.

**Example:**

**Approach:
**

- Create a global variable as String =
**path**. - Do the
*preorder* - if
, return.*root is greater than Sum required* - If not then, add root to the path and update the required sum (
).*sum=sum-root.data* - if
, means we have found the path, print it.*sum required =0* - See the code for better understanding.

**Code:**

**Output**:

1 2 7 1 3 6