Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions linkedlist.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
using namespace std;
struct ListNode {
double value;
ListNode *next;
};
int main() {
ListNode *head;
head = new ListNode; // Allocate new node
head->value = 16.4; // Store the value
head->next = NULL; // Signify end of list
ListNode *secondPtr = new ListNode;
secondPtr->value = 19.3;
secondPtr->next = NULL; // Second node is end of list
head->next = secondPtr; // First node points to second
// Print the list
cout << "First item is " << head->value << endl;
cout << "Second item is " << head->next->value << endl;
return 0;
}