linkedlist cin and cout use

PHOTO EMBED

Sat Jun 04 2022 06:46:20 GMT+0000 (Coordinated Universal Time)

Saved by @Ranjan_kumar #c++

#include <bits/stdc++.h>

using namespace std;
class node{
    public:
    int d;
    node* next;
};
void printlinkedelements(node* i)
{
    while(i!=NULL)
    {
        cout<<i->d<<" "<<i<<"\n";
        i=i->next;
        
    }
}
void takeinput(node* i)
{
    while(i!=NULL)
    {
        cin>>i->d;
        i=i->next;
    }
}
int main()
{
    node* head=NULL;
    node* second=NULL;
    node* third=NULL;
     
    head=new node();
    second=new node();
    third=new node();
    
  
    head->next=second;

   second->next=third;
   
   third->next=NULL;
   takeinput(head);
   printlinkedelements(head);
    return 0;
}
content_copyCOPY