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

What is wrong with this declaration?

0 Answers  


#include<stdio.h> int main() { int i=0,j=1,k=2,m,n=0; m=i++&&j++&&k++||n++; printf("%d,%d,%d,%d,%d",i,j,k,m,n); }

12 Answers   Capital IQ, Sasken,


What is a stream?

0 Answers  


What is function prototype?

0 Answers  


WHOT IS CHAR?

4 Answers   TCS,






Write a program on swapping (100, 50)

0 Answers   BPL,


What are the different types of control structures in programming?

0 Answers  


Tell us two differences between new () and malloc ()?

0 Answers   Adobe,


Write a program to print fibonacci series without using recursion?

0 Answers  


What is meaning of "Void main" in C Language.

24 Answers   Ford, GU, HCL, IBIBS, JUW, TCS,


the maximum width of a c variable name can be a) 6 characters b) 8 characters c) 10 characters d) 20 characters

2 Answers  


WHY DO WE USE A TERMINATOR IN C LANGUAGE?

2 Answers  


Categories