October 2009
M T W T F S S
    Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Archives

Categories

  • [+]ASP.NET (7) 
  • [+]C# (87) 
  • [—]C++ (13) 
  • [+]Delphi (20) 
  • [+]JavaScript (24) 
  • [+]Regular Expressions (7) 
  • [+]SQL (13) 
  • [+]VB (100) 
  • [+]VB.NET (4) 

Online

Users: 7 Guests, 1 Bot
  • Loading...


    Loading...

    Login






    Register | Lost password?

    Register





    A password will be mailed to you.
    Log in | Lost password?

    Retrieve password





    A confirmation mail will be sent to your e-mail address.
    Log in | Register
  • Program to insert and delete items in circular queue

    /* Program to insert and delete items in circular queue */
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
     int F=0,R=0,N=3,X,Q[10],choice;
     clrscr();
     start:
     printf("Enter your choice 1.Insert 2.Delete 3.Exit:");
     scanf("%d",&choice);
     if(choice==1)
     {
    	if((R+1==F)||(F==1 && R==N))
    	{
    		printf("Queue Overflow.\n");
    	}
    	else
    	{
    		printf("Enter the item to be inserted:");
    		scanf("%d",&X);
    		if(R==N)
    		{
    			R=1;
    		}
    		else
    		{
    			R++;
    		}
    		Q[R]=X;
    		if(F==0)
    		{
    			F=1;
    		}
    	}
     goto start;
     }
     else if(choice==2)
     {
    	if(F==0)
    	{
    		printf("Queue Underflow.\n");
    	}
    	else
    	{
    		X=Q[F];
    		printf("The deleted item is %d.\n",X);
    		if(F==R)
    		{
    			F=R=0;
    		}
    		else if(F==N)
    		{
    			F=1;
    		}
    		else
    		{
    			F++;
    		}
    	}
     goto start;
     }
     else
     {
    	printf("The program for insertion and deletion in circular queue ends here.");
     }
     getch();
    }
    
    /* Output
    Enter your choice 1.Insert 2.Delete 3.Exit:2
    Queue Underflow.
    Enter your choice 1.Insert 2.Delete 3.Exit:1
    Enter the item to be inserted:5
    Enter your choice 1.Insert 2.Delete 3.Exit:1
    Enter the item to be inserted:6
    Enter your choice 1.Insert 2.Delete 3.Exit:1
    Enter the item to be inserted:7
    Enter your choice 1.Insert 2.Delete 3.Exit:2
    The deleted item is 5.
    Enter your choice 1.Insert 2.Delete 3.Exit:2
    The deleted item is 6.
    Enter your choice 1.Insert 2.Delete 3.Exit:1
    Enter the item to be inserted:3
    Enter your choice 1.Insert 2.Delete 3.Exit:1
    Enter the item to be inserted:5
    Enter your choice 1.Insert 2.Delete 3.Exit:1
    Queue Overflow.
    Enter your choice 1.Insert 2.Delete 3.Exit:3
    The program for insertion and deletion in circular queue ends here.
    	  */
    
    Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
    • Digg
    • del.icio.us
    • Bloglines
    • Facebook
    • Google Bookmarks
    • LinkedIn
    • Technorati
    • TwitThis
    • Webnews

    Leave a Reply

     

     

     

    You can use these HTML tags

    <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <font color="" face="" size=""> <span style="">

    Spam Protection by WP-SpamFree Plugin