Listing 4: A function to count up and print the number of nodes in a binary tree.

struct Tree
{
    struct Tree *left;
    struct Tree *right;
};
static int countHelper(struct Tree *t)
{
    int count = 0;
    while (t)
    {   count += 1 + countHelper(t->right);
    t = t->left;
    }
    return count;
}
void doCount(struct Tree *t)
{
    int count = countHelper(t);
    printf("number of nodes in tree = %d\n", count);
}