Skip to main content

Posts

Showing posts from August 9, 2017

QUEUE ARRAY IN PUSH, POP & PEEK OPERATIONS

CODING: #include<stdio.h> #include<conio.h> #define max 50 int q[max],front=-1,rear=-1; void push(); void pop(); void peep(); void display(); void main() { int ch; clrscr(); do {  printf("\nS E L E C T  C H O I C E");  printf("\n1.Insert Element.");  printf("\n2.Delete Element.");  printf("\n3.Peek.");  printf("\n4.Display Element.");  printf("\n5.Exit");  printf("\nEnter the choice:");  scanf("%d",&ch); switch(ch) { case 1: push(); break; case 2: pop(); break; case 3: peep(); break; case 4: display(); break; case 5: return; default: printf("TRY AGAIN."); break; } }while(ch!=5); getch(); } void push() { int num; printf("Enter the Number:"); scanf("%d",&num); if(rear==max-1)  printf("Queue id overflow."); if(rear==-1 && front==-1)  front=rear=0; else  rear++;  q[rear]=num;  printf(&q