i dont know whats going on my singly linked list implementation…please have a look at it…link to solution

There are mistakes in your linked list implementation. Consider this definition of makenode function in your code :

``````temp=head;
temp->data=y;
``````

What it is doing? It is just creating a new node, setting it to head. You are not creating a linked list here as you are not setting the next pointers. For correcting it, take another pointer as tail that points to the last node inserted in the list and modify the makenode function this way(Assuming the input is 3 4 0).

``````void makenode (int y){
temp->data=y;
temp->next=NULL;
if(tail==NULL)
{
head=temp;   // list is empty, so we make temp as both head and tail.
tail=temp;   // eg list is now 3->NULL and tail and head points to this node with value 3.
}
else{  // list contains atleast one node.
tail->next=temp;  // 3->4->NULL, tail is 3 and temp is 4
tail=temp;  // we make tail as 4, so the list now has head=node with value3, and tail with //node as value 4. Similarly it'll move on.
}
}
``````

Also, You are setting head as 0. Always prefer setting the pointer to NULL.