Implementating code for the linked list using pointer’s


#include <iostream>

using namespace std;

class Node {  // Single Linked list node structure definition 

public:
    int data; // variable to keep the data
    Node* next; // pointer to point to the next node

};

// function to take initial node of the linked list to traverse and print the node value's
void printNode(Node* n)
{
    while (n != NULL) {
        cout<< n->data << "\n";
        n = n->next;
    }
}

int main()
{

    Node* head = NULL;
    Node* second = NULL;
    Node* third = NULL;

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

    head->data = 230;
    head->next = second;

    second->data = 2;
    second->next = third;

    third->data = 45;
    third->next = NULL;

    printNode(head);

    return 0;
}