title: Calculate Average Number in a Binary Search Tree
body: <p>I want to calculate average . The tree has 4 informations: data,number, left and right. The average for all nodes is = multiply for data and number / total number  .</p>
  
  <pre><code>struct node{
  int number;
  int data;
  struct node *right;
  struct node *left;  
  }
  typedef struct node nod;   
  typedef struct node* nodePtr;
  typedef struct node** nodePtrPtr;
   int main(){
   nodePtr a=NULL;
  
  calAverage(&amp;a);
   }
   void calAverage(nodePtrPtr tree){
   {
     nodePtr g;
     double average, sum=0,num,n,s=0;
     int k,z=0;
      int l,w=0;
  
     if(tree){
      tree=g;
      g-&gt;total_number_of_reviews=k;
      g-&gt;scoreNumber=num;
      sum+=(num*k );
      z+=k;
      }
  
  
      if(tree-&gt;left){
       calAverage(tree-&gt;left);        
      }
  
      if(tree-&gt;right){
       calAverage(tree-&gt;right);       
      }
  
  average=((sum+s)/(z+w));
  printf("%.1lf average ",average);}
  </code></pre>
  
  <p>This code doesnt't work correctly . Do you think I call average method by recursively ?</p>