#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node *next;
};
struct node *head=NULL;
void insertAtEnd()
{
struct node *newnode,*temp;
newnode
= malloc(sizeof(struct node
)); scanf("%d",&newnode
->data
); newnode->next=NULL;
if(head=NULL)
{
head=newnode;
}
else{
temp=head;
while(temp->next!=NULL)
{
temp=temp->next;
}
temp->next=newnode;
}
}
int main()
{ int n;
printf("enter the number of nodes"); for (int i = 0; i < n; i++)
{
insertAtEnd();
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CnN0cnVjdCBub2RlewogICAgaW50IGRhdGE7CiAgICBzdHJ1Y3Qgbm9kZSAqbmV4dDsKfTsKc3RydWN0IG5vZGUgKmhlYWQ9TlVMTDsKdm9pZCBpbnNlcnRBdEVuZCgpCnsKICAgIHN0cnVjdCBub2RlICpuZXdub2RlLCp0ZW1wOwogICAgbmV3bm9kZT0gbWFsbG9jKHNpemVvZihzdHJ1Y3Qgbm9kZSkpOwogICAgc2NhbmYoIiVkIiwmbmV3bm9kZS0+ZGF0YSk7CiAgICBuZXdub2RlLT5uZXh0PU5VTEw7CiAgICBpZihoZWFkPU5VTEwpCiAgICB7CiAgICAgICAgaGVhZD1uZXdub2RlOwogICAgfQogICAgZWxzZXsKICAgICAgICB0ZW1wPWhlYWQ7CiAgICAgICAgd2hpbGUodGVtcC0+bmV4dCE9TlVMTCkKICAgICAgICB7CiAgICAgICAgICAgIHRlbXA9dGVtcC0+bmV4dDsKICAgICAgICB9CiAgICAgICAgdGVtcC0+bmV4dD1uZXdub2RlOwogICAgfQp9CmludCBtYWluKCkKeyAgIGludCBuOwogICAgcHJpbnRmKCJlbnRlciB0aGUgbnVtYmVyIG9mIG5vZGVzIik7CiAgICBzY2FuZigiJWQiLG4pOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiAgICB7CiAgICAgICAgaW5zZXJ0QXRFbmQoKTsKICAgIH0KICAgIAp9