Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include <stdlib.h>
- #define n 5
- int main()
- {
- int queue[n],ch=1,front=0,rear=0,i,j=1,x=n, arbitrary[100];
- printf("Farmer and Tractors");
- printf("\n1.Insert money \n2.Extract money \n3.Display all envelopes \n4.Exit");
- while(ch)
- {
- printf("\nEnter the Choice:");
- scanf("%d",&ch);
- switch(ch)
- {
- case 1:
- if(rear==x)
- printf("\n Queue is Full");
- else
- {
- printf("\n Enter no %d envelope:",j++);
- scanf("%d",&queue[rear++]);
- }
- break;
- case 2:
- if(front==rear)
- {
- printf("\n Envelope is empty");
- }
- else
- {
- printf("\n Money taken: %d",queue[--rear]);
- x++;
- }
- break;
- case 3:
- printf("\n Envelope Elements are:\n ");
- if(front==rear)
- printf("\n Envelope is Empty");
- else
- {
- for(i=front; i<rear; i++)
- {
- printf("%d",queue[i]);
- printf("\n");
- arbitrary[i++];
- }
- }
- break;
- case 4:
- exit(0);
- default:
- printf("Wrong");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement