Hello friend, here you will find the all program in c language.Today our topic is circular queue in c language.To connect with us please subscribe us and for any query you can text me at gmail, Instagram.
happy coding😁
- circular queue
#include<stdio.h> #include<stdlib.h> #define max 20 int queue[max],front=-1,rear=-1; void display() { int i; for(i=front;i<=rear;i++) { printf("\t%d",queue[i]); } } void enqueue() { int x; printf("enter the number to add :"); scanf("%d",&x); if(rear==max) { printf("\nthe queue is overflow"); return; } else if(front==-1) { front++; rear++; queue[rear]=x; } else { rear++; queue[rear]=x; } } void dequeue() { if(front==-1) printf("\nUnderflow"); else if(front==rear) front=rear=-1; else front++; } main() { int choice; while(1) { printf("\n\nFollowing are the choice"); printf("\nMENU\n1.ENQUEUE\n2.DEQUEUE\n3.DISPLAY\n4.EXIT\n"); scanf("%d",&choice); switch(choice) { case 1: enqueue(); break; case 2: dequeue(); break; case 3: display(); break; case 4: exit(0); break; default: printf("\nEntere valid choice"); break; } } } this code is written by www.techsayright.blogspot.com |
happy coding😁
إرسال تعليق
Hii