hi
my program should implement queue using stack
h make a code
but i still have error
if an one can tell me what is he error

#include<stdio.h>
 #include<conio.h>
 #include<process.h>
 int in_top=-1;
 int out_top=-1;
 void in_stack_push(int item);
 int in_stack_pop();
 void out_stack_push();
 int out_stack_pop();
 int insert_queue[20],delete_queue[20];
 
void main()
 {
 int i,ch,item;
 clrscr();
 while(1)
 {
 printf("\n1. Insert");
 printf("\n2. Delete");
 
printf("\nEnter Your Choice:- ");
 scanf("%d",&ch);
 switch(ch)
 {
 case 1:
 printf("\n\nEnter the Element in Queue:- ");
 scanf("%d",&item);
 in_stack_push(item);
 break;
 case 2:
 printf("Element Deleted:-%d",out_stack_pop());
 break;
 default:
 printf("Thank You For using queue using two stack");
 getche();
 exit(0);
 }
 }
 }
 void in_stack_push(int item)
 {
 if(in_top>20)
 printf("Queue Full");
 else
 insert_queue[++in_top]=item;
 }
 int in_stack_pop()
 {
 if(in_top>=0)
 return insert_queue[in_top--];
 }
 
void out_stack_push()
 {
 if(in_top==-1)
 {
 printf("Queue Empty");
 }
 else
 {
	 while(in_top>=0){
 delete_queue[++out_top]=in_stack_pop();
 }
 }
 int out_stack_pop()
 {
 if(out_top==-1)
 {
 out_stack_push();
 }
 if(out_top<0 && in_top<0)
 return 0;
 
if(out_top>=0)
 return delete_queue[out_top--];
 }

I think this question would be better asked in the C forum, as the program you posted has no significant C++ content.

What part is tested and which function are you now testing? You should indicate the location of your bug or give only part of the program you work with which manifest the bug with hard coded state, input to produce bug, output you are getting, output you should get, what you have tried to do to fix it.

Presumably the brace mismatch at the end of out_stack_push() isn't a typo. You need one more closing brace before starting out_stack_pop().

hi

one error which i found out is

in the switch case u have used getche() which should be getch()

This article has been dead for over six months. Start a new discussion instead.