#include<stdio.h>
#include<stdlib.h>
struct Node
{
    int data;
    struct Node*next;
};
int main()
{
    struct Node*head=NULL.*newcode.*temp;
    int n;
    printf("Enter no of nodes :");
    scanf("%d\n",&n);
    for(int i=0;i<n;i++)
    {
        newnode=(struct Node*)malloc(sizeof(struct Node));
        if(newnode==NULL)
        {
            printf("Memory allocation failed\n");
            return 1;
        }
        printf("Enter data for node %d : ",i+1);
        scanf("%d",&newnode->data);
        newnode->next=NULL;
        if(head==NULL)
        {
            head=newnode;
            temp=newnode;
        }
        else
        {
            temp->next=newnode;
            temp=newnode;
        }
    }
    printf("\nLinked list");
    temp=head;
    while(temp!=NULL)
    {
        printf("%d ->",temp->data);
        temp=temp->next;
    }
    printf("NULL\n");
    temp=head;
    while(temp!=NULL)
    {
        struct node*nextnode=temp->next;
        temp=newnode;
    }
    return 0;
}