Write a program that reads a list of integers from the keyboard, creates a linke
ID: 3619065 • Letter: W
Question
Write a program that reads a list of integers from the keyboard, creates a linked list from them, and prints the result. Insert each integer into the tail. The list of the data is the following: 12, 23, -56, 69, 71, 15, -36, -99 Write a function that accepts the linked list of the (a), and returns the data in the node with the minimum key value. Write a function that traverses the linked list of the (a), and deletes any nodes whose data fields are negative. Write a program that adds and subtracts polynomials. Each polynomial is to be represented as a linked list.Explanation / Answer
//hope this will help you, containing allfunctions. #include#include#includestruct node{int a;struct node * next;}*first=NULL,*last=NULL,*ptr;//link list linklistinsert(int num){if(first == NULL){last = first = (struct node *)malloc(sizeof(struct node));first ->a = num;first ->next=NULL;}else{last ->next = (struct node *)malloc(sizeof(struct node));last = last->next;last ->a = num;last ->next=NULL;}return;}void print_nodes(){struct node *x;for(x=first; x!=NULL; x=x->next){printf(" -> %d ",x->a);}printf(" ");return;}void find_min(){struct node *x;int min;min = first->a;for(x=first; x!=NULL; x=x->next){if(min > x->a)min =x->a;}printf(" Minimum is :%d ",min);return;}void del_neg(){struct node *x,*previous;while(1){for(x=first; x!=NULL; x=x->next){if (x->a < 0)break;previous=x;}if(x ==NULL)return;if(x==first){first = first->next;}else{previous->next = x->next;}free(x);}}int main(){int num;struct node *x,*previous;printf("Enter numbers to insert in linklist , press 0 to end the input :");do{scanf("%d",&num);if(num!=0)insert(num);}while(num != 0);find_min();print_nodes();del_neg();printf(" After del_neg linklist is :");print_nodes();system("pause");return 0;}Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.