Think very carefully about the code you have for stepping through the list looking for where you can append your new value, especially the last line inside that loop body:
while(nodeptr->next){
nodeptr=nodeptr->next;
nodeptr->next=newNode;
}
Were you to actually single-step your code through a debugger, examining the list after each statement, you would see the problem instantly.
solved My linked list code in c++ is only appending one value