I need to write a function that will create new nodes as the user inputs values for them. The even values are supposed to be put into nodes on one end and the odd values are supposed to be put into nodes on the other end. My program was working fine when I was accepting all values the same way but with the if else statement it will only let me enter two or three numbers. This is the first time I have tried to create a linked list so any help would be greatly appreciated. THANK YOU!Code://--- Definition of push() void Stack::push(const StackElement & value) { Stack::NodePointer ptr; if(value%2==0) first = new Stack::Node(value, first); else{ ptr = first; while(ptr != 0) ptr = new Stack::Node(value, NULL); } }
(typedef int StackElement;
typedef Node * NodePointer)