fork download
  1. #include <stdio.h>
  2. int main( )
  3. {
  4. int queue[10];
  5. int max,num,i;
  6. int front=0,rear;
  7. //printf("Enter the size of queue");
  8. scanf("%d",&max);
  9. //printf("Enter the no of elements in queue");
  10. scanf("%d",&num);
  11. //printf("Enter the elements of queue");
  12. printf("Queue before deletion : ");
  13. for(i=0;i<num;i++)
  14. {
  15. scanf("%d",&queue[i]);
  16. printf(" %d\t",queue[i]);
  17. }
  18. printf("\n");
  19. front = 0;
  20. rear = num -1 ;
  21. printf("Front end : %d\n",front);
  22. printf("Rear end : %d\n",rear);
  23. if (front == -1 && rear == -1)
  24. {
  25. printf("Underflow");
  26. }
  27. else
  28. {
  29. front = front +1;
  30. }
  31. printf("Queue after deletion :");
  32. for(i=front;i<=rear;i++)
  33. {
  34. printf(" %d\t",queue[i]);
  35. }
  36. printf("\n");
  37. printf("Front end : %d\n",front);
  38. printf("Rear end : %d\n",rear);
  39. return 0;
  40. }
Success #stdin #stdout 0s 2296KB
stdin
10
6
25
40
30
10
20
15
stdout
Queue before deletion :  25	 40	 30	 10	 20	 15	
Front end : 0
Rear end : 5
Queue after deletion : 40	 30	 10	 20	 15	
Front end : 1
Rear end : 5