Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linkedlist.cpp #473

Open
wants to merge 6 commits into
base: revert-448-new_code
Choose a base branch
from
Open

linkedlist.cpp #473

wants to merge 6 commits into from

Conversation

ShubhamSamanta-1
Copy link

// Linked list implementation in C++

#include<bits/stdc++.h>
#include
using namespace std;

// Creating a node
class Node {
public:
int value;
Node* next;
};

int main() {
Node* head;
Node* one = NULL;
Node* two = NULL;
Node* three = NULL;

// allocate 3 nodes in the heap
one = new Node();
two = new Node();
three = new Node();

// Assign value values
one->value = 1;
two->value = 2;
three->value = 3;

// Connect nodes
one->next = two;
two->next = three;
three->next = NULL;

// print the linked list value
head = one;
while (head != NULL) {
cout << head->value;
head = head->next;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants