//function to insert a new node at the head of the list node* InsertAtHead(node* head,int x) { node* temp = new node(); //dynamically allocate a new node temp->data =x; //sets the data part to the required value temp->next=head; //sets the link part head =temp; return head; //returns the head pointer to calling function ie.main() }