> For the complete documentation index, see [llms.txt](https://nitinranganath.gitbook.io/data-structures/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://nitinranganath.gitbook.io/data-structures/binary-tree/finding-sum-of-all-nodes.md).

# Finding Sum of All Nodes

```c
int findSum(struct Node *ptr) {

    int x, y;
    
    if (ptr) {
        x = findHeight(ptr -> left);
        y = findHeight(ptr -> right);
        return x + y + ptr -> data;
    }
    return 0;

}
```

Contributed by Nitin Ranganath
