static int sumOfAllBinaryTreeElements(treeNode *rootNode) { if (rootNode == NULL) return 0; else return sumOfAllBinaryTreeElements(rootNode->leftChild) + rootNode->val + sumOfAllBinaryTreeElements(rootNode->rightChild); }
above mention function is member function of my Tree ADT class you can check complete program here
A Developer
Gy@n!