123 Eng

### Engineering the engineers™

Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

Computer Science / IT
Electronics
Electrical
Mechanical
Chemical
Civil

CAT / MBA

GMAT / Foreign MBA
Latest Jobs

Displaying  Source Code(s)

 Implentation of queue using arrays - QUEUE.C -------------------------------------------------------------------------------- Description : Implentation of queue using arrays Code : /* Implentation of queue using arrays - QUEUE.C */ # include # include # define SIZE 10 int arr[SIZE], front = -1, rear = -1, i ; void enqueue() ; void dequeue() ; void display() ; void main() { int ch ; clrscr() ; do { printf(" [1].ENQUEUE [2].DEQUEUE [3].Display [4].Exit
) ; printf(" Enter your choice [1-4] : ") ; scanf("%d", &ch) ; switch(ch) { case 1 : enqueue() ; break ; case 2 : dequeue() ; break ; case 3 : display() ; break ; case 4 : break ; default : printf(" Invalid option
) ; getch() ; } } while(ch != 4) ; getch() ; } void enqueue() { if(rear == SIZE - 1) { printf(" Queue is full (overflow)
) ; getch() ; return ; } rear++ ; printf(" Enter the element to ENQUEUE : ") ; scanf("%d", &arr[rear]) ; if(front == -1) front++ ; } void dequeue() { if(front == -1) { printf(" Queue is empty (underflow)
) ; getch() ; return ; } printf(" The DEQUEUE element is : %d
, arr[front]) ; getch() ; if(front == rear) front = rear = -1 ; else front++ ; } void display() { if(front == -1) { printf(" Queue is empty (underflow)
) ; getch() ; return ; } printf(" The elements in queue are : FRONT ->") ; for(i = front ; i <= rear ; i++) printf(" ... %d", arr[i]) ; printf(" ... <- REAR
) ; getch() ; }

Contribute content or training reports / feedback / Comments
job placement papers