When building the list its printing the first element twice can any one figure this out

here is the code pls check

in the inserttail function at line 29

void insertattail(node*&head,int data){
if(head == NULL) {
head = new node(data);
return; // add this return statement else 2 nodes were being formed
}

Can i have any other alternative to build the list without using the end point as -1

If so make the required change in the code https://ide.codingblocks.com/s/241682

No sir it is the only way to take input
like thats how the question is designed so there is no other way