#include <iostream>
using namespace std;

class node{
    public:
    int data;
    node* next;
};

node* head;
node* tail;

void create(){
    int val;
    int i=0;
    while(cin>>val){
        node* temp = new node();
        temp->data = val;
        if(i==0){
            temp->next=NULL;
            head = tail = temp;
        }
        else{
            tail->next = temp;
            tail = temp;
        }
        i++;
    }
    cout<<"Length of linkedlist: "<<i<<"\n";
}

void print(){
    node* ptr = head;
    while(ptr != NULL){
        cout<<ptr->data<<"->";
        ptr=ptr->next;
    }
    cout<<"NULL";
}

int main() {
    create();
    print();
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: