×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Insert a node into a Circular Singly linked list
Forward and Reverse Display of node of a Circular Singly linked list - Link list - C Language
761    Arnab De    27/09/2019

Display a Circular Singly linked list

We can display the data of the circular singly linklist in two process

  1. Front to end
  2. End to front

We can easily program it using recursive function

softetechnologies
#include<stdio.h>
#include<conio.h>
struct linklist
{
	int i;
	struct linklist *next;
};
typedef struct linklist node;

//prototype declaration

void ftol(node *,node *);
void ltof(node *,node *);

node *head;
int main()
{
	int c,i,pos;	
	while(1)
	{
		printf("2. First to last display\n");
		printf("3. last to First display\n");
		printf("15. Exit\n");
		printf("Enter Your choice : ");
		scanf("%d",&c);
		switch(c)
		{
			case 2:
				ftol(head,head); // First to last display
				break;
			case 3:
				ltof(head,head); // last to First display
				break;
			case 15:
				exit(0);
				
		}
	}
	return 0;	
}
softetechnologies
void ftol(node *l,node *h)
{
	if(l->next!=h)
	{
		printf("%d\n",l->i);
		ftol(l->next,h);
	}
	else
	{
		printf("%d\n",l->i);
	}
}
void ltof(node *l,node *h)
{
	if(l->next!=h)
	{
		ltof(l->next,h);
		printf("%d\n",l->i);
	}
	else
	{
		printf("%d\n",l->i);
	}
}
softetechnologies
Insert a node into a Circular Singly linked list
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Swami Vivekananda
Fill the brain with high thoughts, highest idrals, place them day and night before you, and out of that will come great work.
Swami Vivekananda
3787
37.16
Today So Far
Total View (Lakh)
softetechnologies
01/01/2018     34102
28/06/2017     30587
26/05/2018     29418
02/08/2017     28490
25/06/2018     24453
15/05/2017     24273
01/08/2017     22969
06/07/2017     22777
21/04/2018     19043
14/07/2017     17966
softetechnologies