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

1)what are limitations for recursive function? 2)write a program to read a text file and count the number of characters in the text file

1 Answers  


Why data types in all programming languages have some range? Why ritche have disigned first time likethat?Why not a single data type can support all other types?

2 Answers   Excel,


Explain what is the difference between a string and an array?

0 Answers  


Should I learn c before c++?

0 Answers  


How can I sort a linked list?

0 Answers  






How can I find out the size of a file, prior to reading it in?

0 Answers  


suppose there are five integers write a program to find larger among them without using if- else

2 Answers  


how can i get output like this? 1 2 3 4 5 6

6 Answers   Excel,


In which area global, external variables are stored?

3 Answers  


what is mean by Garbage collection ? Please answer me. Advance thanks.

4 Answers   Excel,


which is faster execution: loops or recursion?

3 Answers  


What is the difference between arrays and pointers?

0 Answers  


Categories