2
Most read
4
Most read
5
Most read
C Program To Implement Linked List Using Array Abstract Data Type
#include<stdio.h>
#include<conio.h>
#include<alloc.h>
#include<stdlib.h>
voidcreate( )
voidinsert( )
voiddelete()
voiddisplay( )
struct node
{
intdata;
struct node *link;
};
struct node *first= NULL, *last= NULL, *next,*prev,*cur;
voidmain( )
{
intch;
clrscr( );
printf ("nSINGLYLINKED LIST");
do
{
printf ("n1.CREATE n 2.INSERTn 3.DELETE n 4.EXIT n");
printf ("nENTER YOUR CHOICE: ");
scanf ("%d",&ch );
switch(ch)
{
case 1:
create( );
display( );
break;
case 2:
insert( );
display( );
break;
case 3:
delete( );
display( );
break;
case 4:
exit(0);
}
} while( ch<= 3)
}
voidcreate( )
{
cur = ( struct node*)malloc(sizeof (structnode));
printf ("nENTER THE DATA:");
scanf ("%d", &cur?data);
cur?link= NULL;
first= cur;
last= cur;
}
voidinsert( )
{
intpos,c = 1;
cur = (structnode*)malloc(sizeof (structnode) );
printf (“ENTERTHE DATA :”);
scanf (“%d”,&cur?data);
printf(“ENTERTHE POSITION:”);
scanf (“%d”,&pos );
if ( (pos= = 1)&& (first!= NULL) )
{
cur?link= first;
first= cur;
}
else
{
next= first;
while (c< pos )
{
prev= next;
next= prev?link;
c++;
}
if ( prev= = NULL)
{
printf (“nINVALIDPOSITION n”);
}
else
{
cur?link= prev?link;
prev?link =cur;
if (cur?link= = NULL)
{
last= cur;
}
}
}
}
voiddelete()
{
intpos,c=1;
printf (“ENTERTHE POSITION :”);
scanf (“%d”,&pos);
if (first= = NULL)
{
printf (“nLIST IS EMPTY n”);
}
else if (pos= = 1&& first?link== NULL)
{
printf(“Ndeletedelementis%dn”,cur?data);
free(cur);
}
else
{
next= first;
while (c< pos )
{
prev= next;
next= next?link;
c++;
}
prev?link =next?link;
next?link=NULL;
if (next= = NULL)
{
printf (“nINVALIDPOSITION n“);
}
else
{
printf (“nDELETED ELEMENT IS%dn”,next?data);
free (next);
if(prev?link== NULL)
{
last= prev;
}
}
}
}
voiddisplay( )
{
cur = first;
while (cur!= NULL)
{
printf (“n%d”,cur?data);
cur = cur?link;
}
}
C Program to implement List ADT using Arrays
#include<stdio.h>
#include<conio.h>
#define MAX 10
void create();
void insert();
void deletion();
void search();
void display();
int a,b[20], n, p, e, f, i, pos;
void main()
{
//clrscr();
int ch;
char g='y';
do
{
printf("n main Menu");
printf("n 1.Create n 2.Delete n 3.Search n 4.Insert n 5.Displayn 6.Exit n");
printf("n Enter your Choice");
scanf("%d", &ch);
switch(ch)
{
case 1:
create();
break;
case 2:
deletion();
break;
case 3:
search();
break;
case 4:
insert();
break;
case 5:
display();
break;
case 6:
exit();
break;
default:
printf("n Enter the correct choice:");
}
printf("n Do u want to continue:::");
scanf("n%c", &g);
}
while(g=='y'||g=='Y');
getch();
}
void create()
{
printf("n Enter the number of nodes");
scanf("%d", &n);
for(i=0;i<n;i++)
{
printf("n Enter the Element:",i+1);
scanf("%d", &b[i]);
}
}
void deletion()
{
printf("n Enter the position u want to delete::");
scanf("%d", &pos);
if(pos>=n)
{
printf("n Invalid Location::");
}
else
{
for(i=pos+1;i<n;i++)
{
b[i-1]=b[i];
}
n--;
}
printf("n The Elements after deletion");
for(i=0;i<n;i++)
{
printf("t%d", b[i]);
}
}
void search()
{
printf("n Enter the Element to be searched:");
scanf("%d", &e);
for(i=0;i<n;i++)
{
if(b[i]==e)
{
printf("Value is in the %d Position", i);
}
else
{
printf("Value %d is not in the list::", e);
continue;
}
}
}
void insert()
{
printf("n Enter the position u need to insert::");
scanf("%d", &pos);
if(pos>=n)
{
printf("n invalid Location::");
}
else
{
for(i=MAX-1;i>=pos-1;i--)
{
b[i+1]=b[i];
}
printf("n Enter the element to insert::n");
scanf("%d",&p);
b[pos]=p;
n++;
}
printf("n The list after insertion::n");
display();
}
void display()
{
printf("n The Elements of The list ADT are:");
for(i=0;i<n;i++)
{
printf("nn%d", b[i]);
}
}

More Related Content

PPTX
Constructor in java
PPTX
Stack - Data Structure - Notes
PDF
c++ lab manual
PPTX
Method overloading
PPTX
Dynamic memory allocation in c
PPTX
Garbage collection
PPTX
Java - Generic programming
PPTX
Storage classes in C
Constructor in java
Stack - Data Structure - Notes
c++ lab manual
Method overloading
Dynamic memory allocation in c
Garbage collection
Java - Generic programming
Storage classes in C

What's hot (20)

PDF
Data Structures Practical File
PDF
Java Basic Oops Concept
PDF
Managing I/O in c++
PPT
Applet life cycle
PPTX
PPTX
File in C language
PPTX
Programming in c Arrays
PPTX
Data Structures in Python
PPTX
JAVA AWT
PPTX
Technical aptitude Test 1 CSE
PDF
Object oriented programming c++
PPTX
Templates in C++
PDF
4 pillars of OOPS CONCEPT
PDF
Compiler unit 2&3
PPTX
Interface in java
PDF
PPTX
File handling in Python
PPT
Strings
PPS
Java Exception handling
Data Structures Practical File
Java Basic Oops Concept
Managing I/O in c++
Applet life cycle
File in C language
Programming in c Arrays
Data Structures in Python
JAVA AWT
Technical aptitude Test 1 CSE
Object oriented programming c++
Templates in C++
4 pillars of OOPS CONCEPT
Compiler unit 2&3
Interface in java
File handling in Python
Strings
Java Exception handling
Ad

Similar to C program to implement linked list using array abstract data type (20)

DOC
Final ds record
PPTX
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
PPTX
EC2311 – Data Structures and C Programming
DOCX
What is Linked List in C.docx
DOCX
Array imp of list
DOCX
01 list using array
PDF
TutorialII_Updated____niceupdateprogram.pdf
PDF
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
DOCX
Linked list imp of list
PPTX
Ll.pptx
PPTX
linked list.pptx
PPT
Linked list1.ppt
PPT
Unit ii(dsc++)
PPTX
UNIT I LINEAR DATA STRUCTURES – LIST .pptx
PPT
Unit7 C
PDF
Linked list
PPTX
Linked list
PPTX
Adt of lists
PPTX
linkedlistforslideshare-210123143943.pptx
PPT
DS Unit 2.ppt
Final ds record
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
EC2311 – Data Structures and C Programming
What is Linked List in C.docx
Array imp of list
01 list using array
TutorialII_Updated____niceupdateprogram.pdf
Solution#includestdio.h#includeconio.h#includealloc.h.pdf
Linked list imp of list
Ll.pptx
linked list.pptx
Linked list1.ppt
Unit ii(dsc++)
UNIT I LINEAR DATA STRUCTURES – LIST .pptx
Unit7 C
Linked list
Linked list
Adt of lists
linkedlistforslideshare-210123143943.pptx
DS Unit 2.ppt
Ad

Recently uploaded (20)

PDF
737-MAX_SRG.pdf student reference guides
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PPTX
Current and future trends in Computer Vision.pptx
PPTX
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
Abrasive, erosive and cavitation wear.pdf
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PPTX
introduction to high performance computing
PPTX
Amdahl’s law is explained in the above power point presentations
PPTX
Module 8- Technological and Communication Skills.pptx
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PPTX
communication and presentation skills 01
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
737-MAX_SRG.pdf student reference guides
Information Storage and Retrieval Techniques Unit III
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Current and future trends in Computer Vision.pptx
ASME PCC-02 TRAINING -DESKTOP-NLE5HNP.pptx
Fundamentals of Mechanical Engineering.pptx
Abrasive, erosive and cavitation wear.pdf
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
introduction to high performance computing
Amdahl’s law is explained in the above power point presentations
Module 8- Technological and Communication Skills.pptx
August 2025 - Top 10 Read Articles in Network Security & Its Applications
Exploratory_Data_Analysis_Fundamentals.pdf
communication and presentation skills 01
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
distributed database system" (DDBS) is often used to refer to both the distri...
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
Influence of Green Infrastructure on Residents’ Endorsement of the New Ecolog...
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION

C program to implement linked list using array abstract data type

  • 1. C Program To Implement Linked List Using Array Abstract Data Type #include<stdio.h> #include<conio.h> #include<alloc.h> #include<stdlib.h> voidcreate( ) voidinsert( ) voiddelete() voiddisplay( ) struct node { intdata; struct node *link; }; struct node *first= NULL, *last= NULL, *next,*prev,*cur; voidmain( ) { intch; clrscr( ); printf ("nSINGLYLINKED LIST"); do { printf ("n1.CREATE n 2.INSERTn 3.DELETE n 4.EXIT n"); printf ("nENTER YOUR CHOICE: "); scanf ("%d",&ch ); switch(ch) { case 1: create( ); display( ); break; case 2: insert( ); display( ); break; case 3: delete( ); display( ); break; case 4: exit(0); } } while( ch<= 3) } voidcreate( ) { cur = ( struct node*)malloc(sizeof (structnode)); printf ("nENTER THE DATA:");
  • 2. scanf ("%d", &cur?data); cur?link= NULL; first= cur; last= cur; } voidinsert( ) { intpos,c = 1; cur = (structnode*)malloc(sizeof (structnode) ); printf (“ENTERTHE DATA :”); scanf (“%d”,&cur?data); printf(“ENTERTHE POSITION:”); scanf (“%d”,&pos ); if ( (pos= = 1)&& (first!= NULL) ) { cur?link= first; first= cur; } else { next= first; while (c< pos ) { prev= next; next= prev?link; c++; } if ( prev= = NULL) { printf (“nINVALIDPOSITION n”); } else { cur?link= prev?link; prev?link =cur; if (cur?link= = NULL) { last= cur; } } } } voiddelete() { intpos,c=1; printf (“ENTERTHE POSITION :”); scanf (“%d”,&pos); if (first= = NULL) { printf (“nLIST IS EMPTY n”);
  • 3. } else if (pos= = 1&& first?link== NULL) { printf(“Ndeletedelementis%dn”,cur?data); free(cur); } else { next= first; while (c< pos ) { prev= next; next= next?link; c++; } prev?link =next?link; next?link=NULL; if (next= = NULL) { printf (“nINVALIDPOSITION n“); } else { printf (“nDELETED ELEMENT IS%dn”,next?data); free (next); if(prev?link== NULL) { last= prev; } } } } voiddisplay( ) { cur = first; while (cur!= NULL) { printf (“n%d”,cur?data); cur = cur?link; } }
  • 4. C Program to implement List ADT using Arrays #include<stdio.h> #include<conio.h> #define MAX 10 void create(); void insert(); void deletion(); void search(); void display(); int a,b[20], n, p, e, f, i, pos; void main() { //clrscr(); int ch; char g='y'; do { printf("n main Menu"); printf("n 1.Create n 2.Delete n 3.Search n 4.Insert n 5.Displayn 6.Exit n"); printf("n Enter your Choice"); scanf("%d", &ch); switch(ch) { case 1: create(); break; case 2: deletion(); break; case 3: search(); break; case 4: insert(); break; case 5: display(); break; case 6: exit(); break; default: printf("n Enter the correct choice:"); } printf("n Do u want to continue:::"); scanf("n%c", &g);
  • 5. } while(g=='y'||g=='Y'); getch(); } void create() { printf("n Enter the number of nodes"); scanf("%d", &n); for(i=0;i<n;i++) { printf("n Enter the Element:",i+1); scanf("%d", &b[i]); } } void deletion() { printf("n Enter the position u want to delete::"); scanf("%d", &pos); if(pos>=n) { printf("n Invalid Location::"); } else { for(i=pos+1;i<n;i++) { b[i-1]=b[i]; } n--; } printf("n The Elements after deletion"); for(i=0;i<n;i++) { printf("t%d", b[i]); } } void search() { printf("n Enter the Element to be searched:"); scanf("%d", &e); for(i=0;i<n;i++) { if(b[i]==e) { printf("Value is in the %d Position", i); } else { printf("Value %d is not in the list::", e); continue;
  • 6. } } } void insert() { printf("n Enter the position u need to insert::"); scanf("%d", &pos); if(pos>=n) { printf("n invalid Location::"); } else { for(i=MAX-1;i>=pos-1;i--) { b[i+1]=b[i]; } printf("n Enter the element to insert::n"); scanf("%d",&p); b[pos]=p; n++; } printf("n The list after insertion::n"); display(); } void display() { printf("n The Elements of The list ADT are:"); for(i=0;i<n;i++) { printf("nn%d", b[i]); } }