Answers for "use an inbuilt linked list in c++"

C++
2

c++ linked list

#include<bits/stdc++.h>
using namespace std;
struct Node
{
    Node *next;
    int data;
};
void print(Node *n)
{
    while(n!=NULL)
    {
        cout<<n->data<<" ";
        n=n->next;
    }
}
int main()
{
    Node* head,*second,*third = NULL;


    head=new Node();
    second=new Node();
    third=new Node();

//First Node
    head->data=1;
    head->next=second;

//Second Node
    second->data=2;
    second->next=third;

//Third Node
    third->data=3;
    third->next=NULL;
    print(head);
//@rahulsharmaah
}
Posted by: Guest on February-19-2022

Code answers related to "use an inbuilt linked list in c++"

Browse Popular Code Answers by Language