struct node *add()
{
struct node *ptr;
if(ptr!=NULL){
s=s+ptr->item;
ptr->left=add();
ptr->right=add();
}
printf("%\nd",s);
return ptr;
}
void sumlevel(struct node *ptr,int k){
if(k==1)
{
s=0;
ptr=add();
}
sumlevel(ptr->left,k-1);
//ptr=ptr->right;
sumlevel(ptr->right,k-1);
}
int main()
{
int n,k=1;
int ch,d1,d2;
struct node *ptr;
ptr=build();
printf("\nBINARY TREE\n");
display(ptr);
ch=height(ptr);
printf("\nHeight is %d\n",ch);
while(k<=ch)
{printlevel(ptr,k);
printf("\n");
k++;
}
count(ptr);
d1=height(ptr->left);
d2=height(ptr->right);
printf("\ndiameter of tree is %d",d1+d2);
k=1;
while(k<=ch){
sumlevel(ptr,k);
k++;
}
display(ptr);
return 0;
}
I have declared ‘s’ as global can you please tell me the error
Thanks for clearing my previous doubts on time