diff --git a/C++/DisplayinLL b/C++/DisplayinLL new file mode 100644 index 0000000..66e40a1 --- /dev/null +++ b/C++/DisplayinLL @@ -0,0 +1,47 @@ +#include +using namespace std; + +class Node{ +public: + int data; + Node* next; +}; + +int main() { + + int A[] = {3, 5, 7, 10, 15}; + + Node* head = new Node; + + Node* temp; + Node* last; + + head->data = A[0]; + head->next = nullptr; + last = head; + + // Create a Linked List + for (int i=1; idata = A[i]; + temp->next = nullptr; + + // last's next is pointing to temp + last->next = temp; + last = temp; + } + + // Display Linked List + Node* p = head; + + while (p != nullptr){ + cout << p->data << " -> " << flush; + p = p->next; + } + + return 0; +}