New Member FAQ
|
Forums
|
Earn Revenue
|
Distance Education
|
Help Topics
|
Admissions 2013
Login
Register
Articles
Practice Tests
Ask Experts
Question Papers
Jobs
Universities
Colleges
Courses
Schools
Gift Shop
|
Bookmarks
|
Reviews
|
Learn English
|
Social Hub
|
Training
|
New Posts
|
My India
|
Members
|
Polls
|
Active Members
Today
MANIKANDAN
(117)
mahi patel
(110)
R Pramod
(105)
Last 7 Days
R Pramod
(1011)
K Mohan
(668)
Pritan Tiwari
(516)
more...
Resources
»
Articles/Knowledge Sharing
»
Computer & Technology
C Program of queue using array
Posted Date:
24-Mar-2008
Category:
Computer & Technology
Author:
ashish singh
Member Level:
Gold
Points
: 3
/*Program of queue using array*/
# include
# define MAX 5
int queue_arr[MAX];
int rear = -1;
int front = -1;
main()
{
int choice;
while(1)
{
printf("1.Insert\n");
printf("2.Delete\n");
printf("3.Display\n");
printf("4.Quit\n");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1 :
insert();
break;
case 2 :
del();
break;
case 3:
display();
break;
case 4:
exit(1);
default:
printf("Wrong choice\n");
}/*End of switch*/
}/*End of while*/
}/*End of main()*/
insert()
{
int added_item;
if (rear==MAX-1)
printf("Queue Overflow\n");
else
{
if (front==-1) /*If queue is initially empty */
front=0;
printf("Input the element for adding in queue : ");
scanf("%d", &added_item);
rear=rear+1;
queue_arr[rear] = added_item ;
}
}/*End of insert()*/
del()
{
if (front == -1 || front > rear)
{
printf("Queue Underflow\n");
return ;
}
else
{
printf("Element deleted from queue is : %d\n", queue_arr[front]);
front=front+1;
}
}/*End of del() */
display()
{
int i;
if (front == -1)
printf("Queue is empty\n");
else
{
printf("Queue is :\n");
for(i=front;i<= rear;i++)
printf("%d ",queue_arr[i]);
printf("\n");
}
}/*End of display() */
Did you like this resource? Share it with your friends and show your love!
Tweet
Responses to "C Program of queue using array"
Feedbacks
Post Comment:
Notify me by email when others post comments to this article.
Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
No HTML formatting and links to other web sites are allowed.
This is a strictly moderated site. Absolutely no spam allowed.
Name:
Sign In
to fill automatically.
Email:
(Will not be published, but
required
to validate comment)
Type the numbers and letters shown on the left.
Next Resource:
C Program of queue using circular linked list
Previous Resource:
C Program of queue using linked list
Return to Resources
Post New Resource
Category:
Computer & Technology
Post resources and
earn money
!
More Resources
C Program of priority queue using linked list
C Program for conversion of infix to postfix and evaluation of postfix
C Program to check nesting of parentheses using stack
C Program of input and output restricted dequeue using array
C Program of circular queue using array
C Program to find path matrix by Warshall's algorithm
Popular Tags
Tag posting guidelines
Search Tags
(No tags found.)
Subscribe to Email
Get Jobs by Email
Forum posts by Email
Articles by Email
Awards & Gifts
Online Members
Vineeta Sinha
mistypari
Jebaprincy
Naresh Kumar Behera
mrinalini
MANIKANDAN
ragaven
Kokil Kumar Sarma
arti
bhavani shankar
nisha sharma
More...