Append Numbers to a Linked List Tail
hardQuestion 472Read 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, so print one after the last line.
Your output
Run your code to see the output here...