Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7180217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:18:06+00:00 2026-05-28T17:18:06+00:00

This program is not giving Queue Overflow error message when its full. Why is

  • 0

This program is not giving “Queue Overflow” error message when its full. Why is that so? Is there something wrong with the qfull function? I even tried if(qfull(*r)==1). Even then its not working. It just keeps going on accepting numbers even when its full.

#include<stdio.h>
#include<conio.h>
#include<process.h>
#define QUEUE_SIZE 5

void insert_rear(int,int*,int*);
void delete_front(int*,int*,int*);
void display(int*,int,int);
int qempty(int,int);
int qfull(int);
void main()
{
    int f=0,r=-1,q[10],item,choice;
    for(;;)
    {
    clrscr();
      printf("\t\t\t Ordinary Queue Operation\n\n");
      printf("\t\t\t 1. Push\n");
      printf("\t\t\t 2. Pop\n");
      printf("\t\t\t 3. Display\n");
      printf("\t\t\t 4. Exit\n\n");
      printf("\t\t\t Enter your choice: ");
      scanf("%d",&choice);
      switch(choice)
      {
        case 1:
            printf("Enter the item to be inserted: ");
            scanf("%d",&item);
            insert_rear(item,q,&r);
            continue;
         case 2:
            delete_front(q,&f,&r);
            break;
         case 3:
            display(q,f,r);
            break;
         case 4:
            exit(0);
         default:
            printf("\t\t\t Invalid Input - Try Again");
      }
      getch();
   }
}





void insert_rear(int item,int q[],int *r)
{
    if(qfull(*r)==1)
   {
    printf("\t\t\t Queue Overflow\n");
      return;
   }
   q[++(*r)]=item;
}





void delete_front(int q[],int *f,int *r)
{
    if(qempty(*f,*r))
   {
    printf("\t\t\t Queue Underflow\n");
      return;
   }
   printf("Pop successfull, item deleted = %d",q[(*f)++]);
   if(*f>*r)
   {
    *f=0,*r=-1;
   }
}





void display(int q[],int f,int r)
{
    int i;
   if(qempty(f,r))
   {
    printf("Queue is empty\n");
      return;
   }
   printf("\t\t\t Queue Container\n\n");
   for(i=f;i<=r;i++)
    printf("\t\t\t |%5d|\n",q[i]);
}





int qempty(int f,int r)
{
    return(f>r)?1:0;
}





int qfull(int r)
{
    return(r==QUEUE_SIZE-1)?1:0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:18:07+00:00Added an answer on May 28, 2026 at 5:18 pm

    The problem is that the call to clrscr is clearing the error message from the screen so you are just not seeing the message. If you remove the clrscr I am sure you will see the message before the new menu is drawn to the screen.

    You need to set an error flag indicating the problem and then display the error message when you display the menu.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++ program that is giving this error as soon as the
For some reason this program is saying that 'switch' is not defined. What is
I can not compile, this program is giving me errors. I have already spend
I am not sure why is it giving this error. Braces seem to be
How can I implement generics in this program so I do not have to
This is not homework, I need this for my program :) I ask this
This program I'm doing is about a social network, which means there are users
Ive just started C and I'm trying to do this queue implementation program from
I have written this simple C program that changes the rotation file name. Eg:
Im getting this error when trying to run a program in creating, how shold

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.