0% found this document useful (0 votes)
41 views2 pages

To Insert An Element in A Queue Maintained As An Array

This presentation is on Arrays. Array Nerworks are formed using C programming and other C array programming techniques

Uploaded by

Karan Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

To Insert An Element in A Queue Maintained As An Array

This presentation is on Arrays. Array Nerworks are formed using C programming and other C array programming techniques

Uploaded by

Karan Roy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 2

To insert an element in a Queue

maintained as an array
#define<stdio.h>
#define maxsize 20
Int queue[20],front=-1,rear=-1;
Void insert(int );
Void main()
{ int element;
Char ch=y;
While(ch==y||ch== Y)
{
Printf(enter the element to be
inserted);
Scanf(%d,&element);
Insert( element);
Printf( do you want to enter more
elements);
Scanf(%c,&ch);
}

Void insert( int item)
{
If (rear>=maxsiz-1)
{ printf(overflow);
Break;
}
If (rear==-1)
Front=rear=0;
Else
Rear=rear+1;
Queue[rear]=item;
}

To delete an element in a Queue
maintained as an array
#define<stdio.h>
#define<conoi.h>
#define maxsize 20
Int queue[20],front=-1,rear=-1;
Void delete( );
Void main()
{ Char ch=y;
While(ch==y||ch== Y)
{
Delete();
Printf( do you want to delete
more elements);
Scanf(%c,&ch);
}

Void delete()
{ int element;
If (front<0)
{ printf(underflow);
getch();
break;
}
Element=Queue[front];
If (front==rear)
Front=rear=-1;
Else
Front=front+1;
Printf(the element deleted is%d,
element);
}

You might also like