A linked list program that I wrote using C++ programming language.

 I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.My mobile number here in the Philippines is 09173084360.

Program Listing

#include <cstddef>
#include <iostream>

using namespace std;

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

void print_list(Node * n) {

    while (n != NULL) {
        cout <<"\t" << n->data << "\n";
        n = n->next;
    }
}

int main() {
    Node * head = NULL;
    Node * second = NULL;
    Node * third = NULL;
    Node * fourth = NULL;
    Node * fifth = NULL;
    Node * sixth = NULL;

    head = new Node();
    second = new Node();
    third = new Node();
    fourth = new Node();
    fifth = new Node();
    sixth = new Node();


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

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

    third->data = 30;
    third->next = fourth;

    fourth->data = 40;
    fourth->next = fifth;

    fifth->data = 50;
    fifth->next = sixth;

    sixth->data = 60;
    sixth->next = NULL;

    cout <<"\n\n";
    cout <<"\tLinked List in C++\n\n";
    print_list(head);
    cout <<"\n\n";
    cout <<"\tEnd of Program";
    cout <<"\n";
}

Leave a Reply

Your email address will not be published.