0% found this document useful (0 votes)
22 views2 pages

Linked List Vishnu 10

The document shows code to display a circular linked list. It includes functions to create a circular linked list from an array and display it by traversing from the head node until reaching the head node again.

Uploaded by

Pate Vishnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Linked List Vishnu 10

The document shows code to display a circular linked list. It includes functions to create a circular linked list from an array and display it by traversing from the head node until reaching the head node again.

Uploaded by

Pate Vishnu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

//display of circular linked list

#include<iostream>

using namespace std;

class node

public:

int data;

node *next;

};

void display(node *n);

int main()

int n;

cout<<"enter the no of nodes "<<endl;

cin>>n;

int a[n];

cout<<"enter the data of the linked list "<<endl;

for(int i=0;i<n;i++)

cin>>a[i];

node *head;

node *temp;

node *last;

head=new node();

head=new node();

head->data=a[0];

head->next=NULL;

last=head;

for(int i=1;i<n;i++)
{

temp=new node();

temp->data=a[i];

temp->next=NULL;

last->next=temp;

last=temp;

last->next=head;

display(head);

void display(node *n)

node *p=n;

do

cout<<p->data<<" ";

p=p->next;

while(p!=head);

cout<<endl;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy