q. implement a stack making use of the linked


Q. Implement a stack making use of the linked list. Show the PUSH and POP operations both.

Ans.

Stack implemantation using linked list

# include

# include

struct link

{

int info ;

struct link *next;

}   *start;

struct link * push (struct link * rec)

{

struct link *new_rec;

printf ("\n Input the new value for next location of the stack:") ;

new_rec = (struct link *) malloc (size of

(struct link)) ;

scanf ("%d", &new_rec->info) ;

new_rec->next = rec;

rec = new_rec;

return (rec);

}

struct link * pop (struct link * rec)

{

struct link * temp ;

if (rec == NULL)

{

}

else

{

printf ('\n Stack is empty") ;

temp = rec; rec= temp->next;

printf("the popped element %d", temp->.info);

free(temp) ;

return(rec);

}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: q. implement a stack making use of the linked
Reference No:- TGS0156805

Expected delivery within 24 Hours