sir,
i cannot find the way how to write aprogram by using
array on queue



sir, i cannot find the way how to write aprogram by using array on queue..

Answer / ruchi

#include<stdio.h>
#include<conio.h>
void insert();
void del();
void trav();
int f=-1,r=-1,a[20],n=5;
int main()
{
int ch;
char ch1='y';
clrscr();
while(ch1=='y')
{
printf("\nMEnu ");
printf("\n1.Insertion ");
printf("\n2.Deletion ");
printf("\n3.Traversal ");
printf("\n4.Exit ");
printf("\nEnter your chioce ");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert();
break;
case 2:
del();
break;
case 3:
trav();
break;
case 4:
exit(0);
}
printf("\nDo you want to repeat ");
ch1=getche();
}
}
void insert()
{
int item;
if(r<n-1)
{
printf("\nEnter the element ");
scanf("%d",&item);
if(f==-1)
{
f=0;
r=0;
}
else

r=r+1;
a[r]=item;
}
}
void del()
{
if((f>=0)&&(f<=r))
{
f=f+1;
printf("\nItem is deleted ");
}
else
{
printf("\nUnderflow ");
}
}
void trav()
{
int i;
if((f==-1)||(f>r))
{
printf("\nQueue is empty ");
}
for(i=f;i<=r;i++)
{
printf("%d\n",a[i]);
}
}

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Identify the operators that is not used with pointer a. && b. # c. * d. >>

2 Answers  


What are the Advantages of using macro

0 Answers  


main() { struct test { char c; int i; char m; } t1; printf("%d %d\n", sizeof(t1), sizeof(t1.c)); }

1 Answers   Vector, Vector India,


f(*p) { p=(char *)malloc(6); p="hello"; return; } main() { char *p="bye"; f(p); printf("%s",p); } what is the o/p?

7 Answers   Hughes,


What is the difference between a string and an array?

0 Answers  






What are pragmas and what are they good for?

0 Answers  


what is different between auto and local static? why should we use local static?

0 Answers  


how to multiply two number taking input as a string (considering sum and carry )

2 Answers   Wipro,


What would be an example of a structure analogous to structure c?

0 Answers  


Can you please explain the difference between exit() and _exit() function?

0 Answers  


write a program to find lcm and hcf of two numbers??

1 Answers  


What is the symbol indicated the c-preprocessor?

0 Answers  


Categories