Looking for a Tutor Near You?

Post Learning Requirement »
x

Choose Country Code

x

Direction

x

Ask a Question

x

x
x
x
Hire a Tutor

Data Structure

Loading...

Published in: C / C++
2,631 Views

C Programmings of Data Structure with output.

Sayantan A / Kolkata

8 years of teaching experience

Qualification: M.Tech

Teaches: Chemistry, Computer Science, Mathematics, Physics, GATE Exam, JEXPO, MCA Entrance Exam (JECA), Polytechnic Entrance, Computer, IT

Contact this Tutor
  1. Q 9. Write a menu driven program (in c)for complete implementation of queue using array with insertion, deletion, and display operation. #include #include #define SIZE 50 typedef struct QUEUE int item[SlZE]; int front; int rear; int count; }queue; void init(queue *pq) pq->front = O; pq->rear = -1; pq->count = O; void insertion(queue *pq) if(pq->count >= SIZE-I) printf("queue is full"); else int n; printf("\nenter the item - scanf("%d",&n); pq->item[pq->rear] = n; printf("\ninserted item pq->item[%d] = %d \n", pq->rear, pq- >item[pq->rear]); pq->count++;
  2. void deletion(queue *pq) if(pq->count item[pq->front]; pq->front++; printf("\n\nitem deleted = %d\n",n); pq->count--; void display(queue *pq) if(pq->count front; i rear; i++) printf("\nqueue[%d] = %d",i,pq->item[i]); int main() int c; queue q; init(&q);
  3. scanf("%d",&c); do switch(c) : insertion(&q); break; case 1 case 2 : deletion(&q); break; case 3 : display(&q);break; scanf("%d" &c); }while(c); return O; OUTPUT: I.INSERTION 2.DELETlON enter the item = 4 inserted item pq->item[O] = 4 I.INSERTION 2.DELETlON queue[O] = 4 I.INSERTION 2.DELETlON enter the item = 5 3.DlSPLAY 3.DlSPLAY 3.DlSPLAY inserted item pq->item[l] = 5 I.INSERTION 2.DELETlON 3.DlSPLAY O.EXIT OPTION = 1 O.EXIT OPTION = 3 O.EXIT OPTION = 1 O.EXIT OPTION = 3
  4. queue[O] = 4 queue[l] = 5 I.INSERTION 2.DELETlON item deleted = 4 I.INSERTION 2.DELETlON queue[l] = 5 I.INSERTION 2.DELETlON 3.DlSPLAY 3.DlSPLAY 3.DlSPLAY O.EXIT OPTION = 2 O.EXIT OPTION = 3 O.EXIT OPTION