could you please tell me what is wrong with this code it is compiling but a execution error occured i am unable to find that
am using devc++ compiler
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
typedef struct link
{
int value;
struct link * lchild;
struct link *rchild;
}node;
node *head =NULL;
node* create(node* ,int );
void traverse(node *);
// int height(node *);
int main()
{
int n,i,val;
printf("enter how many node you want to create\n" );
scanf("%d",&n);
for( i=0; i<n; i++)
{
printf("enter ur node value\n");
scanf("%d" ,&val);
head = create(head,val);
}
traverse(head);
//height(head);
return 0;
}
node* create( node *tree ,int val)
{
if(tree==NULL)
{
tree= (node*)malloc(sizeof(node *));
tree->value=val;
tree->rchild=NULL;
tree->lchild=NULL;
}
else
if(val>tree->value)
tree->rchild = create(tree->rchild,val);
else
if(val<tree->value)
tree->lchild=create(tree->lchild, val);
else
if(val==tree->value)
printf("duplicate value");
}
return tree; //here it says there is syntax error
}
void traverse (node *tree)
{
if(tree!=NULL)
{
traverse(tree->lchild);
printf(tree->value);
traverse(tree->rchild);
}
}