You are on page 1of 6

include<stdio.

h>

#define max 4

 int st[max],top=-1,x,i;

void push()

if(top>=max-1)

printf("fully packed \n");

else

top++;

printf("car number \n");

scanf("%d",&x);

st[top]=x;

int pop()

if(top==-1)

printf("no cars \n");

else

x=st[top];

top--;

return x;

printf("\n");

}
}

void display()

if(top==-1)

printf("no cars \n");

else

printf("cars in the parking area \n");

for(int i=top;i>=0;i--)

printf("%d",st[i]);

int main()

do

int c,k;

printf(" 1)push 2)pop 3)display 4)exit \n");

scanf("%d",&c);

switch(c)

case 1: push();break;

case 2: k=pop();break;

case 3:display();break;

case 4:exit(0);

}while(1);
}

QUEUE:

#include<stdio.h>

#define max 9

int a[max];

int front=-1;

int rear=-1;

int isempty()

if(front==-1 && rear==-1)

return 1;

else

return 0;

void enqueue()

int x;

scanf("%d",&x);

if(rear==(max-1))

printf("the queue is full\n");

if (isempty())
{

front=rear=0;

a[rear]=x;

else

rear=(rear+1);

a[rear]=x;

void dequeue()

if (isempty())

printf("the queue is empty\n");

else

front=front+1;

if(front==rear)

front=rear=-1;

int displayfront()

if(front==-1)
{

printf("queue is empty\n");

else

printf("the front is:%d\n",a[front]);

void display()

int i;

for(i=front;i<=rear;i++)

printf("%d\t",a[i]);

int main()

int i=1,choice;

while(i==1)

printf("enter your choice: 1.enqueue 2.dequeue 3.displayfront 4.display queue


5.exit");

scanf("%d",&choice);

switch(choice)

case 1:

enqueue();

break;

case 2:

dequeue();
break;

case 3:

displayfront();

break;

case 4:

display();

break;

case 5:

i=2;

break;