Linked list doubt in code

#include<stdio.h>
#include
#include<stdlib.h>
using namespace std;
typedef struct node
{
int data;
struct node* next;
}node;

node* create(int n)
{
node* head=NULL,*p=NULL,temp=NULL;
int i=0;
for(i=0;i<n;i++)
{
temp=(node
)malloc(sizeof(node));
cin>>temp->data;

	temp->next=NULL;
	if(head==NULL)
	{
		head=temp;
		
	}
	else
	{
		p=head;
		while(p->next!=NULL)
		{
			p=p->next;
			p->next=temp;
		}
	}
}
return head;

}

void display(node* head)
{
node* p=head;
while(p!=NULL)
{
cout<data;
p=p->next;
}
}
int main()
{
int n;
cin>>n;
node* head=NULL;
head=create(n);
display(head);
return 0;

}

why is this code only printing the head?