#include<stdio.h>
#include<stdlib.h>
#define MAXSIZE 10
int Q[ MAXSIZE] , front=- 1 , rear=- 1 ;
void qinsert( int x)
{
if ( rear== MAXSIZE- 1 )
else if ( front==- 1 )
{
front= 0 ;
rear= 0 ;
Q[ front] = x;
}
else
{
rear++;
Q[ rear] = x;
}
}
void qdelete( )
{
if ( front==- 1 )
else if ( front== rear)
{
printf ( "\n %d is removed from Queue." , Q
[ front
] ) ; front=- 1 ;
rear=- 1 ;
}
else
{
printf ( "\n %d is deleted from Queue." , Q
[ front
] ) ; front++;
}
}
void display( )
{
int i;
printf ( "\n The Queue elements are...\n " ) ; if ( front==- 1 )
printf ( "\n No elements in Queue." ) ; else
{
for ( i= front; i<= rear; i++ )
}
}
int main( )
{
int choice, x;
while ( 1 )
{
printf ( "\n 1.Data insert\n 2.Data Delete\n 3.Data Display\n 4.Exit" ) ; printf ( "\n Please, Enter your choice : " ) ; switch ( choice)
{
case 1 : printf ( "\n Please, Enter the element : " ) ; qinsert( x) ;
break ;
case 2 : qdelete( ) ;
break ;
case 3 : display( ) ;
break ;
default : printf ( "\n wrong Choice." ) ; }
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CiNkZWZpbmUgTUFYU0laRSAxMAppbnQgUVtNQVhTSVpFXSxmcm9udD0tMSxyZWFyPS0xOwp2b2lkIHFpbnNlcnQoaW50IHgpCnsKCWlmKHJlYXI9PU1BWFNJWkUtMSkKCQlwcmludGYoIlxuIFF1ZXVlIGlzIEZ1bGwuIik7CgllbHNlIGlmKGZyb250PT0tMSkKCXsKCQlmcm9udD0wOwoJCXJlYXI9MDsKCQlRW2Zyb250XT14OwkKCX0KCWVsc2UKCXsKCQlyZWFyKys7CgkJUVtyZWFyXT14OwoJfQp9CnZvaWQgcWRlbGV0ZSgpCnsKCWlmKGZyb250PT0tMSkKCQlwcmludGYoIlxuIFF1ZXVlIGlzIEVtcHR5LiIpOwoJZWxzZSBpZihmcm9udD09cmVhcik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3.Data Display
4.Exit
Please, Enter your choice :
Please, Enter the element :
1.Data insert
2.Data Delete
3.Data Display
4.Exit
Please, Enter your choice :
Please, Enter the element :
1.Data insert
2.Data Delete
3.Data Display
4.Exit
Please, Enter your choice :
Please, Enter the element :
1.Data insert
2.Data Delete
3.Data Display
4.Exit
Please, Enter your choice :
457 is deleted from Queue.
1.Data insert
2.Data Delete
3.Data Display
4.Exit
Please, Enter your choice :
The Queue elements are...
87 320
1.Data insert
2.Data Delete
3.Data Display
4.Exit
Please, Enter your choice :