CJCoding With Joseph
15free / daySign inCreate account

Append Numbers to a Linked List Tail

Read integers from standard input until the input runs out, appending each value to the TAIL of a singly linked list so the list holds them in the order they arrived. Append — do not prepend and reverse afterwards.

Then print the list, the number of nodes, and the sum of all the values. For the input:

5 12 3

the program prints exactly the output shown in Expected Output.

Format: List: then, for EVERY node, a space, the value, a space and ->, followed by a space and NULL after the last node (so an empty list would print List: NULL). Then Nodes:  with the count and Sum:  with the total.

Free the memory you allocate before the program ends — this question checks for memory leaks.

Expected Output:

List: 5 -> 12 -> 3 -> NULL
Nodes: 3
Sum: 20

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
Pointers
📥 Auto-Input:
5 12 3\n
This input is automatically fed to your program's stdin
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.