// #include <stdio.h>
// #include <stdlib.h>

// struct Node{
//     int data;
//     struct Node* next;
// };

// struct Node* createNode(int a){
//     struct Node* n=(struct Node *)malloc(sizeof(struct Node));
//     n->data=a;
//     n->next=NULL;
//     return n;
// }
// void insertAtEnd(struct Node** head,int a){
//     struct Node* newNode=createNode(a);
//     if(*head==NULL){
//         *head=newNode;
//         return;
//     }
//     struct Node* tem=*head;
//     while(temp->next!=NULL){
//         temp=temp->next;
//     }
// }
// void display(struct Node* head){
//     struct Node* temp=head;
//     while(temp!=NULL){
//         printf("%d->",temp->data);
//         temp=temp->next;
//     }
// }


// int main() {
//     struct Node* head=NULL;
//     insertAtEnd(&head,10);
//     insertAtEnd(&head,20);
//     insertAtEnd(&head,30);
//     insertAtEnd(&head,40);
//     insertAtEnd(&head,50);
//     return 0;

// }

#include <stdio.h>
#include <stdlib.h>

struct Node{
    int data;
    struct Node* next;
};

struct Node* createNode(int a){
    struct Node* n=(struct Node *)malloc(sizeof(struct Node));
    n->data=a;
    n->next=NULL;
    return n;
}



void insertAtEnd(struct Node** head,int a){
    struct Node* newNode=createNode(a);
    if(*head==NULL){
        *head=newNode;
        return;
    }
    struct Node* tem=*head;
    while(temp->next!=NULL){
        temp=temp->next;
    }
    temp->next=newNode;
}
void insertAtK(struct Node** head,int a,int k){
    struct Node* n=createNode(a);
    struct Node* temp=*head;
    int i=1;
    while(temp->next!=NULL && i<k-1){
        temp=temp->next;
        i=i+1;
    }
    struct Node* b=temp->next;
    temp->next=n;
    n->next=b;
  }
void display(struct Node* head){
    struct Node* temp=head;
    while(temp!=NULL){
        printf("%d->",temp->data);
        temp=temp->next;
    }
    
}

int main() {
    struct Node* head=NULL;
    insertAtEnd(&head,10);
    insertAtEnd(&head,20);
    insertAtEnd(&head,30);
    insertAtEnd(&head,40);
    insertAtEnd(&head,50);
    display(head);
    return 0;

}