try this..after passing root pointer and 0 to the function void summer(node *r,int sum) { if(r) { if(!r->left && !r->right) { cout<<sum+r->data<<endl; return; } summer(r->left,sum+(r->data)); summer(r->right,sum+(r->data)); } }
On Fri, Oct 7, 2011 at 10:31 PM, Deepak arora <deepakarora...@gmail.com>wrote: > thanks tpawan10 > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- *Dheeraj Sharma* -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.