Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Experiment 1 (PreLab task to be prepared in the lab) 1.1) Examine and test the below menu driven program for Insertion (I) and Deletion (D)

image text in transcribed

image text in transcribed

Experiment 1 (PreLab task to be prepared in the lab) 1.1) Examine and test the below menu driven program for Insertion (I) and Deletion (D) operation using stack structure. #include #include #include #include #define STACKSIZE 5 struct stack { int items [STACKSIZE]; int top; void push(struct stack * ,int); int pop (struct stack *); void main(void) { struct stack s; int xx; char optype; s.top=-1; do { printf ("Enter Operation type "); scanf(" %c", &optype); switch (optype) { case 'I': printf ("ENTER input Number "); scanf("%d",&xx); push(&s, xx); break; } case 'D':{ printf("%d %s", pop (&s)," is deleted "); break; } default .printf("%s", "Illegal Oparation code "); } }while (optype!='E'); } int pop (struct stack *ps) (int x; if (ps->top==-1) printf("%s","stack underflow"); exit(1); } else x=ps->items (ps->top]; ps-top-ps->top - 1; } return x; } void push(struct stack *ps, int x) if (ps->top == STACKSIZE-1) { printf("s","stack overflow "); exit(1); ) else! ps->top-ps->top + 1;// ++ (ps->top) ps->items [ps->top]=x; 1.2 )Using below structure write the same menu driven Insertion/Deletion main program, Push() and Pop() functions. struct person { int empnr; char name[12]; int age; }; struct stack { struct person items[6]; int top; }; Use the following input data(empnr, name, age) for your menu driven program 123 ALI 25 345 AYSE 22 1 D E Your program will display empnr, name and age when you call POP() function each time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions