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

int main() {
    struct node*head=NULL ,*newnode,*temp;
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        newnode=(struct node*)malloc(sizeof(struct node));
        if(newnode==NULL){
            printf("memory allocation failed");
            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("\n");
    temp=head;
    while(temp!=NULL){
        struct node*newnode=temp->next;
        temp=newnode;
    }
return 0;
}