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 bitwise operator?

1 Answers   IBM,


2)#include<iostream.h> main() { printf("Hello World"); } the program prints Hello World without changing main() the o/p should be intialisation Hello World Desruct the changes should be a)iostream operator<<(iostream os, char*s) os<<'intialisation'<<(Hello World)<<Destruct b) c) d)none of the above

4 Answers   Siemens,


Write a program in c to print * * * * * *******

1 Answers  


Can we declare a function inside a function in c?

0 Answers  


Write a program that takes a 5 digit number and calculates 2 power that number and prints it.

1 Answers  






Please write the area of a RIGHT ANGLED TRIANGLE.

1 Answers  


main() { char *p1="Name"; char *p2; p2=(char *)malloc(20); while(*p2++=*p1++); printf("%s\n",p2); }

4 Answers   CitiGroup,


Why string is used in c?

0 Answers  


How to Throw some light on the splay trees?

0 Answers  


What does the file stdio.h contain?

0 Answers  


difference between spiral and waterfall model

1 Answers  


praagnovation

0 Answers  


Categories