SlideShare a Scribd company logo
ARRAY IMPLEMENTATION
#include <stdio.h>
#include<stdlib.h>
void insertbeg(int);
void insertend(int);
void insertmiddle(int,int);
void display();
int delete(int);
int search(int);
int a[5];
int i=0;
int main()
{
int ch,num,loc,pos;
while(1)
{
printf("1.insert at the beginingn");
printf("2.insert at the endn");
printf("3.insert at the middlen");
printf("4.display the listn");
printf("5.delete from the listn");
printf("6.search an element in the listn");
printf("7.exitn");
printf("enter ur choicen");
scanf("%d",&ch);
switch(ch)
{
case 1: printf("enter the element to be insertedn");
scanf("%d",&num);
insertbeg(num);
break;
case 2: printf("enter the element to be insertedn");
scanf("%d",&num);
insertend(num);
break;
case 3: printf("enter the element and position inthe listn");
scanf("%d%d",&num,&pos);
insertbeg(num);
break;
case 4: display();
break;
case 5: printf("enter the element to be deletedn");
scanf("%d",&num);
loc=delete(num);
if(loc==-1)
printf("element not found in the listn");
else
printf("element successfully deletedn");
break;
case 6: printf("enter the element to be searchedn");
scanf("%d",&num);
loc=search(num);
if(loc==0)
printf("element not found in the listn");
break;
case 7: exit(1);
break;
default: printf("u entered invalid choicen");
}
}
}
void insertbeg(int num)
{
int j;
for(j=i;j>0;j--)
{
a[j]=a[j-1];
}
a[j]=num;
i++;
}
void insertend(int num)
{
a[i]=num;
i++;
}
void insertmiddle(int num,int pos)
{
int j;
for(j=i;j>=pos;j--)
{
a[j]=a[j-1];
}
a[j]=num;
i++;
}
void display()
{
int j;
for(j=0;j<i;j++)
{
printf("%dn",a[j]);
}
}
int delete(int num)
{
int j,pos;
for(j=0;j<i;j++)
{
if(a[j]==num)
break;
}
if(j>i)
return -1;
pos=j;
for(j=pos;j<i;j++)
{
a[j]=a[j+1];
}
a[j-1]=NULL;
}
int search(int num)
{
int j;
for(j=0;j<i;j++)
{
if(a[j]==num)
{
printf("element found at %dn",j+1);
break;
}
}
return 0;
}

More Related Content

DOCX
Array imp of list
PPT
StackArray stack3
PPTX
Array menu
DOCX
C program to implement linked list using array abstract data type
DOC
Final ds record
PPTX
Stack using Array
PPTX
Stack using Linked List
Array imp of list
StackArray stack3
Array menu
C program to implement linked list using array abstract data type
Final ds record
Stack using Array
Stack using Linked List

What's hot (20)

DOCX
array implementation
PDF
Stack Data Structure
DOCX
01 list using array
PDF
Bcsl 033 data and file structures lab s1-1
DOCX
Circular queue
PPTX
DS- Stack ADT
DOCX
DOCX
PPTX
ภาษาซี
PPTX
ภาษาซี
PDF
DOCX
New microsoft word document
array implementation
Stack Data Structure
01 list using array
Bcsl 033 data and file structures lab s1-1
Circular queue
DS- Stack ADT
ภาษาซี
ภาษาซี
New microsoft word document
Ad

Viewers also liked (20)

DOC
выступление
PPTX
Studmco
DOC
De Kampioenen van Schaakclub Rijs!
PPTX
LAVC Opening Day power pt.
PDF
2011 worldfootwearyearbook
PPTX
Polypill poster Istanbul, Nov 2014
PDF
Omma Social Presentation '14 NYC
PDF
Manitoulin 2014
PDF
إعداد المعلم في مجال التعليم الإلكتروني
PDF
Automotive Glazing - Current & Future Technology Trends
PPTX
Spaii presentation
DOCX
Mortgage whitepaper may 2011
PPTX
Mídias sociais 2013 e o que você deve observar
PDF
кизеловский завод
PPTX
Energy at home calculation lesson
PPSX
Η άλλη πλευρά της Ελλάδας
DOCX
Εγώ είμαι εγώ. Εσύ και εγώ είμαστε εμείς_ ΦΕ
PPT
The animals
PPT
HBLSS: Improving on Innovation
выступление
Studmco
De Kampioenen van Schaakclub Rijs!
LAVC Opening Day power pt.
2011 worldfootwearyearbook
Polypill poster Istanbul, Nov 2014
Omma Social Presentation '14 NYC
Manitoulin 2014
إعداد المعلم في مجال التعليم الإلكتروني
Automotive Glazing - Current & Future Technology Trends
Spaii presentation
Mortgage whitepaper may 2011
Mídias sociais 2013 e o que você deve observar
кизеловский завод
Energy at home calculation lesson
Η άλλη πλευρά της Ελλάδας
Εγώ είμαι εγώ. Εσύ και εγώ είμαστε εμείς_ ΦΕ
The animals
HBLSS: Improving on Innovation
Ad

Similar to Array list (20)

DOCX
One dimensional operation of Array in C- language
DOCX
Data Structures Using C Practical File
DOC
Main ds manual
PDF
Data Structures Practical File
PDF
Array data structure
PDF
Array data structure
PPTX
DSA - Array.pptx
DOCX
Data structure output 1
PPT
Array Presentation (EngineerBaBu.com)
DOCX
Data structure and algorithm lab spiral (1) (4) (1).docx
PPTX
Arrays
DOCX
ADA FILE
PDF
DATA STRUCTURE USING C & C++
PDF
DSU C&C++ Practical File Diploma
PPT
358 33 powerpoint-slides_5-arrays_chapter-5
PPTX
implementation adtarraybasedimplementatio.pptx
DOCX
Data Structure Project File
PDF
DSA UNIT II ARRAY AND LIST - notes
PDF
1D Array
One dimensional operation of Array in C- language
Data Structures Using C Practical File
Main ds manual
Data Structures Practical File
Array data structure
Array data structure
DSA - Array.pptx
Data structure output 1
Array Presentation (EngineerBaBu.com)
Data structure and algorithm lab spiral (1) (4) (1).docx
Arrays
ADA FILE
DATA STRUCTURE USING C & C++
DSU C&C++ Practical File Diploma
358 33 powerpoint-slides_5-arrays_chapter-5
implementation adtarraybasedimplementatio.pptx
Data Structure Project File
DSA UNIT II ARRAY AND LIST - notes
1D Array

Recently uploaded (20)

PPTX
Cell Structure & Organelles in detailed.
PPTX
Cell Types and Its function , kingdom of life
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Institutional Correction lecture only . . .
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Cell Structure & Organelles in detailed.
Cell Types and Its function , kingdom of life
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Complications of Minimal Access Surgery at WLH
Pharmacology of Heart Failure /Pharmacotherapy of CHF
A systematic review of self-coping strategies used by university students to ...
Final Presentation General Medicine 03-08-2024.pptx
human mycosis Human fungal infections are called human mycosis..pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
GDM (1) (1).pptx small presentation for students
Institutional Correction lecture only . . .
202450812 BayCHI UCSC-SV 20250812 v17.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Microbial disease of the cardiovascular and lymphatic systems
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharma ospi slides which help in ospi learning
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Supply Chain Operations Speaking Notes -ICLT Program

Array list

  • 1. ARRAY IMPLEMENTATION #include <stdio.h> #include<stdlib.h> void insertbeg(int); void insertend(int); void insertmiddle(int,int); void display(); int delete(int); int search(int); int a[5]; int i=0; int main() { int ch,num,loc,pos; while(1) { printf("1.insert at the beginingn"); printf("2.insert at the endn"); printf("3.insert at the middlen"); printf("4.display the listn"); printf("5.delete from the listn"); printf("6.search an element in the listn"); printf("7.exitn"); printf("enter ur choicen"); scanf("%d",&ch); switch(ch) { case 1: printf("enter the element to be insertedn"); scanf("%d",&num); insertbeg(num); break; case 2: printf("enter the element to be insertedn"); scanf("%d",&num); insertend(num); break; case 3: printf("enter the element and position inthe listn"); scanf("%d%d",&num,&pos); insertbeg(num); break; case 4: display(); break; case 5: printf("enter the element to be deletedn"); scanf("%d",&num);
  • 2. loc=delete(num); if(loc==-1) printf("element not found in the listn"); else printf("element successfully deletedn"); break; case 6: printf("enter the element to be searchedn"); scanf("%d",&num); loc=search(num); if(loc==0) printf("element not found in the listn"); break; case 7: exit(1); break; default: printf("u entered invalid choicen"); } } } void insertbeg(int num) { int j; for(j=i;j>0;j--) { a[j]=a[j-1]; } a[j]=num; i++; } void insertend(int num) { a[i]=num; i++; } void insertmiddle(int num,int pos) { int j; for(j=i;j>=pos;j--) { a[j]=a[j-1]; } a[j]=num; i++; } void display() { int j; for(j=0;j<i;j++) { printf("%dn",a[j]);
  • 3. } } int delete(int num) { int j,pos; for(j=0;j<i;j++) { if(a[j]==num) break; } if(j>i) return -1; pos=j; for(j=pos;j<i;j++) { a[j]=a[j+1]; } a[j-1]=NULL; } int search(int num) { int j; for(j=0;j<i;j++) { if(a[j]==num) { printf("element found at %dn",j+1); break; } } return 0; }