can anybody help me in queue program asap plz

This is a discussion on can anybody help me in queue program asap plz within the C Programming forums, part of the General Programming Boards category; Code: #include<stdio.h> #include<process.h> struct que { int no; struct que *next; } *front=NULL,*rear=NULL; typedef struct que que; void en() { ...

  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    2

    can anybody help me in queue program asap plz

    Code:
    #include<stdio.h>
    #include<process.h>
    struct que
    {
    int no;
    struct que *next;
    }
    *front=NULL,*rear=NULL;
    typedef struct que que;
    void en()
    {
    que*p;
    printf("enter the no.");
    scanf("%d",&p->no);
    if(front==rear)
    {
     front=p;
     rear=p;
    }
    else
    {
    p->next=NULL;
    rear->next=p;
    rear=p;
    }
    }
    int de()
    {
    que*p;
    p=front;
    if(front==rear)
    {
    front=NULL;
    rear=NULL;
    }
    else
    {
    front=front->next;
     printf("deleted no. is%d",p->no);
    }
    }
    int main()
    {
    int ch;
    printf("\nenter ur choice \n 1. queue \n 2.deque \n 3.traverse ");
    scanf("%d",&ch);
    switch(ch)
    {
    case 1:
    {
    void en();
    break;
    }
    case 2:
    {
    int de();
    break;}
    }
    }

    why this program closes after i press 1

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,588
    1. Your indentation needs work -> SourceForge.net: Indentation - cpwiki
    2. Don't claim your post is urgent
    3.
    Code:
    case 1:
    {
    void en();
    break;
    }
    All you did was prototype the function - you didn't call it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    1,290
    I'll get you started with these definitions for queue and node. See if you can figure out the rest:

    Code:
    typedef struct _QUEUE{
    struct _QUEUE *front;
    struct _QUEUE *rear;
    }QUEUE, *PQUEUE;
    
    typedef struct _NODE{
    struct _NODE *next;
    int number;
    }NODE, *PNODE;
    
    QUEUE queue_of_nodes;
    NODE example_node;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with a basic program, please help ASAP
    By MrPriest in forum C Programming
    Replies: 12
    Last Post: 04-26-2010, 03:15 AM
  2. Help !!! need to write program asap
    By Adamakl in forum C Programming
    Replies: 3
    Last Post: 11-12-2006, 10:03 AM
  3. can anybody fix this program for me ASAP
    By smallslugbug in forum C++ Programming
    Replies: 4
    Last Post: 04-28-2006, 07:25 AM
  4. help ASAP w/program
    By CindyLou in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2002, 07:36 PM
  5. error in program help ASAP pleeease
    By karen in forum C++ Programming
    Replies: 2
    Last Post: 10-17-2001, 02:07 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21