Write a C program to implement Queues using Singly Linked Lists.
The operations to be performed are
1. Insert Front
2. Delete Rear
3. Display
1. Insert Rear
2. Delete Front
3. Display

i solve but there are error:

// Structure of each node in SLL
struct node
	int info;
   struct node *link;
typedef struct node* NODE;

// Function to create a new node from the free memory...
NODE createNode()
	NODE temp;

   temp=(NODE)malloc(sizeof(struct node));

   return temp;

// Insert a new node at front of the SLL...

NODE insertFront(NODE first, int item)
	NODE temp;

   	printf("\n\n Sorry..!!! Cant Insert..Bcz..Memory Allocation Failed..");
		return first;

   printf("\n\n Success..!! %d is inserted at front of SLL successfully..Proceed",item);

	return first;

void display(NODE first)
	NODE temp;
   for(temp=first; temp!=NULL; temp=temp->link)
   	printf("\n\n %d", temp->info);

NODE deleteRare(NODE last)
	NODE temp;

   printf("\n\n %d is deleted from the rare of the list...Proceed.",temp->info);

	return last;

void main()
	NODE last,first=NULL;
   int i, item;

   	printf("\n\n Enter the item to be inserted at front of the list--->");
		scanf("%d", &item);
      first=insertFront(first, item);
   printf("\n\n The contents of the list created are:");

   printf("\n\n Lets delete the item at front of the list..");

   printf("\n\n The contents of the list after deletion are:");

   printf("\n \n Press any key to stop...");

please help me i want in night

Edited 5 Years Ago by Nick Evan: Added CODE tags

Write a C program...

I don't go to a java website asking for c++ help. Why do you come to a c++ forum asking for C help.

I just don't understand why this is such a common occurance.

sorry>>>>>there are noooooooooooooooo one help us in this website

please >>>................................

Edited 5 Years Ago by Nick Evan: Use the &quot;edit&quot; button to edit your post

Could you explain your logic for deleteRear as the argument passed to it looks like NULL and if it was passed correct last node it's next pointer would be NULL, so how you are updating the second last node which actualy is needed?

Of course after this helper function works, you must do the actual en/dequeue functions(actually insertFront ie enqueue you have already, if it is properly tested to work in all cases.)

Edited 5 Years Ago by pyTony: n/a

What is the exact issue that you are facing ?

FYI if you use google you will find lots of examples of linked list code all over internet

Edited 5 Years Ago by abhimanipal: n/a

your code segment for deleteRear is probably flawed.
you must traverse upto the node preceding the node to be deleted i.e

NODE temp = start;*/the top of the link list should be stored in a global vaiable since this is a single link link-list*/
while( temp->link!= last )
   temp = temp->next;
temp->next = last->next; /* assign end pointer to the preceding node*/


Your loop is missing a condition. What if the node to be deleted is not present in the linked list ?
This problem is usually solved by returning from the function when temp->link == NULL

This article has been dead for over six months. Start a new discussion instead.