All linked list operation

I am trying to write a code which can perform all the linked list operation.
Whenever I try to perform operations like inserting anywhere in the linked list “case 3” and deletion at a specified position “case 6” and then print the linked list I am not getting the desired output and it runs for an infinite loop.

Ps: I am running this code offline on code blocks ide.

hello @div_yanshu07
can u please mention the test case for which it is not working as expected.
it will help me debug u code fast

I have already mentioned case 3 and case 6 which are calling function insertionatspecifiedpos and deletionatspecifiedpos

i mean what input u r giving ?

1-2-3 is the linked list and I am trying to delete 2 so when I try to print, It should print 1-3 but it doesn’t and same when I try to add element at specific position to make the linked list look like 1-2-4-3 it doesn’t print.

in ur deletspecific position u need to add case for position equal 1 , in this case u need to update ur head pointer as well

@div_yanshu07
image

for the case that u mentioned , u code is stucked in this while loop.
this loop will never be false because ur prev is equal to temp.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.