CJCoding With Joseph
15free / daySign inCreate account

Two-Node Linked List

A struct Node holds an int value and a struct Node *next pointer (a self-referential struct). Build a two-node list where the first node has value 1 and points to a second node with value 2 (whose next is NULL). Traverse the list from the head and print the values joined by  ->  (see Expected Output).

The two nodes can be plain local variables. There is no trailing newline.

Expected Output:

1 -> 2

= newline. No newline after the last line.

Hints4 available
Topics:
Structs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (p, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.