I am getting a run time error

/* getting a run time error SIGSEGV */

#include <stdio.h>
#include <stdlib.h>

struct node
{
int data ;
struct node *link;

};

void append(struct node **q,int num)
{
struct node *temp,r;
if(q==NULL)
{
temp=(struct node
)malloc(sizeof (struct node));
temp->data=num;
temp->link=NULL;
*q=temp;
}
else
{
temp=q;
/
go to the last node */
while (temp!=NULL)
{
temp=temp->link;

   }

   /* add a new node */
   r=(struct node*)malloc(sizeof (struct node));
   r->data=num;
   r->link=NULL;
   temp->link=r;

}
}
void display(struct node *q)
{
while(q!=NULL)
{
printf("%d",q->data);
printf("\n");
q=q->link;
}

}

void main()
{
struct node *p=NULL;

append(&p,30);
append(&p,55);
display┬ž;

}

I made few changes in your code, where you did wrong.

/* FIXED */

#include <stdio.h>
#include <stdlib.h>

struct node{
	int data ;
	struct node *link;
};

void append(struct node **q,int num){
	struct node *temp,*r; // here it should be *r because you are using malloc which returns the addreass location 
	if(*q==NULL){
		temp=(struct node*)malloc(sizeof (struct node)); // here it should be struct node * because of memory location which it pointer
		temp->data=num;
		temp->link=NULL;
		*q=temp;
	}
	else{
		temp=*q; // here it shoulb be *q instead q because it'a double pointer
		/* go to the last node */
		while (temp->link!=NULL){ // here it should be temp->link instead temp because we need last node to insert new node
			temp=temp->link;
		}
		/* add a new node */
		r=(struct node*)malloc(sizeof (struct node));
		r->data=num;
		r->link=NULL;
		temp->link=r;
	}
}

void display(struct node *q){
	while(q!=NULL){
		printf("%d",q->data);
		printf("\n");
		q=q->link;
	}

}

int main(void){
	struct node *p=NULL;

	append(&p,30);
	append(&p,55);
	display(p);
}