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

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there a way to jump out of a function or functions?

636


Did c have any year 2000 problems?

655


what is the role you expect in software industry?

1658


When is a void pointer used?

678


Explain how can you be sure that a program follows the ansi c standard?

865






Why does everyone say not to use gets?

608


What are the applications of c language?

624


What are data types in c language?

584


Write a program of advanced Fibonacci series.

707


Hai,I have done with my bachelor of commerce and planing to ms,please suggest me how to convince vo for shifting from commerce to computers. Visa on 8 DEC 2014  Npu university

1599


How can I send mail from within a c program?

581


Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.

1726


What are the types of macro formats?

606


Is c procedural or object oriented?

580


What are the 4 types of functions?

573