Build a Singly Linked List by adding student roll numbers!
Hi! I'm Teju 👋 Students enter the class and type their roll numbers.
We store them in a Singly Linked List – each new student is added to the end!
Enter roll numbers one by one (or multiple separated by space). Stop by entering -1.
Input: Positive integers (roll numbers), end with -1
Output: All roll numbers in the order they arrived
Data Structure: Singly Linked List (dynamic insertion)
A Singly Linked List is a chain of nodes. Each node has:
• Data (roll number)
• Pointer to next node
We maintain a head (start) and add new nodes at the end.
Each new roll number becomes a new node at the end →
Start adding roll numbers...
Linked List Elements: