Please someone helps me with this question I must submit the answer tomorrow. The program is not working properly as is suppose to ; I am not getting the result shown below.
Write a program that accepts numbers from the user and stores them in a linked list called allnum until a negative number is entered, then after the input has been terminated print the elements stored in the linked list . then without allocation of new memory place all memory place all even numbers in allnum in the linked list even ,and all the odd numbers in the linked list odd. Finally print the two linked list with proper heading.
Example :
Enter the integer values, - to stop: 2 5 8 3 9 6 1 7 4 -9
The result will be:
The numbers in the linked list are: 2 5 8 3 9 6 1 7 4
The numbers in the even linked list are: 2 8 6 4
The numbers in the odd linked list are: 5 3 9 1 7
This is my program
#include <stdio.h>
#include <stdlib.h>
struct list *make_node(int );
struct list *insert(struct list *,struct list *);
void prt_even_odd(struct list *);
struct list
{
int num;
struct list *next;
};
main()
{
struct numbers *start, *ptr, *head=NULL;
int count=0,input;
printf("Enter a integer.\n");
while (scanf("%d",&input));
{
ptr=make_node(input);
if (count==0)
{
start=ptr;
count++;
}
head=insert(head,ptr);
}
}
struct list *make_node(int numb)
{
struct list *pt;
pt=(struct list *)malloc( sizeof(struct list) );
if (pt==NULL)
{
printf("No more memory.\n");
exit(0);
}
pt->num=numb;
return pt;
}
struct list *insert(struct list *start,struct list *pt)
{
struct list *a=start;
pt->next=start;
start=pt;
return start;
}
void prt_even_odd(struct list *begin)
{
struct list *pt=begin, *temp;
while (pt!=NULL)
{
printf("%d ",pt->num);
temp=pt->next;
pt=temp;
}
return ;
}