Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Help me with this question in C. It only asks to fill out the specific functions

ID: 3728164 • Letter: H

Question

Help me with this question in C. It only asks to fill out the specific functions in the .c file, so please just add those and don't add anything additional or change anything. Thanks.

.h file:

; . Storing and maintaining a linked list. (12 marks) Initialize a single node from a passed string (2 mark) Add a "push" function to add a node to the front of the list (2 marks) Add a "pop" function to remove the first node of a linked list and return a pointer to said node (2 marks) " Deleting Nodes (2 marks) o Delete a single node and free any allocated memory from inside the node (1 mark) o Delete te entire linked list, delete all nodes iteratively (1 mark) Reverse order of the linked list (4 marks)

Explanation / Answer

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#define STRLENGTH 100

struct node

{

char data;

struct node *next;

};

struct node *nw,*temp,*start,*q,*p;

char str[STRLENGTH];

int i;

char AddFront()

{

do{

nw=(struct node*)malloc(sizeof(struct node));

  

printf("Enter the data ");

scanf("%[^ ]%*c", str);

nw->data=str;

nw->next=start;

start=nw;

  

printf("Do u want to Enter more data then enter 1 otherwise 0 ");

scanf("%d",&i);

}while(i==1);

getch();

return 0;

}

int display()

{

temp=start;

printf("Element in linked list are ");

while(temp!=NULL)

{

printf("->%c",temp->data);

temp=temp->next;

}

getch();

return 0;

}

struct node *r,*s;

int posno,g=1;

void RemoveFirstNode()

{

posno=1;

temp=start;

if(posno==1){

start=temp->next;

free(temp);

}

}

int posno1;

void RemoveAnyNode()

{

printf("Enter the position which data u want ot delete ");

scanf("%d",&posno1);

temp=start;

if(posno1==1){

start=temp->next;

free(temp);

}

else{

while(temp!=NULL && g<posno1){

g++;

r=temp;

temp=temp->next;

}

if(temp==NULL)

printf("position does not exist ");

else{

r->next=temp->next;

free(temp);

}

}

}

void DeleteFullList()

{

temp=start;

while(temp!=NULL){

temp=start;

temp=temp->next;

free(temp);

}

printf("SUCCESSFULLY DELETED ALL NODES OF LINKED LIST ");

}

void ReverseLinkList()

{

struct node *prevNode, *curNode;

if(start != NULL)

{

prevNode = start;

curNode = start->next;

start = start->next;

prevNode->next = NULL;

while(start != NULL)

{

start = start->next;

curNode->next = prevNode;

prevNode = curNode;

curNode = start;

}

start = prevNode;

}

}

int main()

{

int op;

do

{

printf("1.AddFront 2.Remove First Node 3.Remove Any Node 4.Delete Full List 5.Reverse Link List 6.display 7.Exit ");

printf("Enter option ");

scanf("%d",&op);

switch(op)

{

case 1:AddFront();

break;

case 2:RemoveFirstNode();

break;

case 3:RemoveAnyNode();

break;

case 4:DeleteFullList();

break;

case 5:ReverseLinkList();

break;

case 6:display();

break;

case 7:exit(0);

break;

}

}while(op<8);

getch();

return 0;

}