Insertion in linked list

while we are inserting at the end, why head is passed by reference what difference it is making please explain it again as i ddnt understand it from video

@Learning_bunny passing by reference allows you to make changed to the pointer i.e if you do not pass by reference and you make some changes to pointer in the function those changes wont be reflected in the main function. Since we do change the value of head pointer in the insert in end function( when head is NULL) we need to pass by reference.

https://ide.codingblocks.com/s/207532 in this code i am trying to insert at the end of the list and when i am passing head by value then it is not showing any value and when passing it by reference then the list is printed in reverse order why is it so???

if you want to insert at back you should assign n to temp->next not head. please see the rectified code

in your code also when i am passing the head by value the it is not printing anything i mean while we are inserting back by function inserth we are not making any change in head pointer then how its pass is effecting the output

in inserth function when head is NULL it get assigned new value, so we need to pass if by reference, else changes made will not be carried into main.

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.