Linked List Taking Input

Bhaiya has made a function build list in which he takes input then call while loop with a condition that data!=-1 but data is 1 so Why it does not go in infinite loop??

-1 is used here to terminate a linked list. So linked list is formed until -1 is given as input.Once -1 is given as input, the loop terminates (as -1 ! = -1 will be false)
So this is not going into an infinite loop

1 Like