SlideShare ist ein Scribd-Unternehmen logo
1 von 3
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;
}

Weitere ähnliche Inhalte

Was ist angesagt? (20)

week-15x
week-15xweek-15x
week-15x
 
array implementation
 array implementation array implementation
array implementation
 
Stack Data Structure
Stack Data StructureStack Data Structure
Stack Data Structure
 
01 list using array
01 list using array01 list using array
01 list using array
 
week-11x
week-11xweek-11x
week-11x
 
Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1Bcsl 033 data and file structures lab s1-1
Bcsl 033 data and file structures lab s1-1
 
week-4x
week-4xweek-4x
week-4x
 
week-18x
week-18xweek-18x
week-18x
 
week-16x
week-16xweek-16x
week-16x
 
week-10x
week-10xweek-10x
week-10x
 
week-1x
week-1xweek-1x
week-1x
 
Circular queue
Circular queueCircular queue
Circular queue
 
DS- Stack ADT
DS- Stack ADTDS- Stack ADT
DS- Stack ADT
 
Qprgs
QprgsQprgs
Qprgs
 
8.1
8.18.1
8.1
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
week-14x
week-14xweek-14x
week-14x
 
12 1 문자열
12 1 문자열12 1 문자열
12 1 문자열
 
New microsoft word document
New microsoft word documentNew microsoft word document
New microsoft word document
 

Andere mochten auch

выступление
выступлениевыступление
выступлениеmagic59
 
De Kampioenen van Schaakclub Rijs!
De Kampioenen van Schaakclub Rijs!De Kampioenen van Schaakclub Rijs!
De Kampioenen van Schaakclub Rijs!schaakclub rijs
 
LAVC Opening Day power pt.
LAVC Opening Day power pt.LAVC Opening Day power pt.
LAVC Opening Day power pt.polaselm
 
2011 worldfootwearyearbook
2011 worldfootwearyearbook2011 worldfootwearyearbook
2011 worldfootwearyearbookCarlos Maculan
 
Polypill poster Istanbul, Nov 2014
Polypill poster Istanbul, Nov 2014Polypill poster Istanbul, Nov 2014
Polypill poster Istanbul, Nov 2014Dr. Anand Sudhalkar
 
Omma Social Presentation '14 NYC
Omma Social Presentation '14 NYCOmma Social Presentation '14 NYC
Omma Social Presentation '14 NYCMichoel Ogince
 
Manitoulin 2014
Manitoulin 2014Manitoulin 2014
Manitoulin 2014jaccalder
 
إعداد المعلم في مجال التعليم الإلكتروني
إعداد المعلم في مجال التعليم الإلكترونيإعداد المعلم في مجال التعليم الإلكتروني
إعداد المعلم في مجال التعليم الإلكترونيmohamed
 
Automotive Glazing - Current & Future Technology Trends
Automotive Glazing  - Current & Future Technology TrendsAutomotive Glazing  - Current & Future Technology Trends
Automotive Glazing - Current & Future Technology TrendsRatna Chatterjee
 
Mortgage whitepaper may 2011
Mortgage whitepaper may 2011Mortgage whitepaper may 2011
Mortgage whitepaper may 2011luis_fleita
 
Mídias sociais 2013 e o que você deve observar
Mídias sociais 2013 e o que você deve observarMídias sociais 2013 e o que você deve observar
Mídias sociais 2013 e o que você deve observarFernando Leroy
 
кизеловский завод
кизеловский заводкизеловский завод
кизеловский заводmagic59
 
Energy at home calculation lesson
Energy at home calculation lessonEnergy at home calculation lesson
Energy at home calculation lessonjaccalder
 
Η άλλη πλευρά της Ελλάδας
Η άλλη πλευρά της ΕλλάδαςΗ άλλη πλευρά της Ελλάδας
Η άλλη πλευρά της Ελλάδαςatanatsis
 
Εγώ είμαι εγώ. Εσύ και εγώ είμαστε εμείς_ ΦΕ
Εγώ είμαι εγώ. Εσύ και εγώ είμαστε εμείς_ ΦΕΕγώ είμαι εγώ. Εσύ και εγώ είμαστε εμείς_ ΦΕ
Εγώ είμαι εγώ. Εσύ και εγώ είμαστε εμείς_ ΦΕEllh
 
HBLSS: Improving on Innovation
HBLSS: Improving on InnovationHBLSS: Improving on Innovation
HBLSS: Improving on Innovationjehill3
 

Andere mochten auch (20)

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

Ähnlich wie Array list

Single linked list
Single linked listSingle linked list
Single linked listSayantan Sur
 
Circular linked list
Circular linked listCircular linked list
Circular linked listSayantan Sur
 
BINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdf
BINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdfBINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdf
BINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdfARYAN20071
 
Data Structures : array operations in c program
Data Structures : array operations in c program Data Structures : array operations in c program
Data Structures : array operations in c program Raghavendra Narayan
 
Double linked list
Double linked listDouble linked list
Double linked listSayantan Sur
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File Rahul Chugh
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language 9096308941
 
Sorting programs
Sorting programsSorting programs
Sorting programsVarun Garg
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shortingargusacademy
 
Data structure output 1
Data structure output 1Data structure output 1
Data structure output 1Balaji Thala
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using CBilal Mirza
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C ProgramsKandarp Tiwari
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignmentsreekanth3dce
 

Ähnlich wie Array list (20)

Single linked list
Single linked listSingle linked list
Single linked list
 
Circular linked list
Circular linked listCircular linked list
Circular linked list
 
BINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdf
BINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdfBINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdf
BINARY SEARCH TREE OPERATIONS #includestdio.h#includestdlib.pdf
 
Data Structures : array operations in c program
Data Structures : array operations in c program Data Structures : array operations in c program
Data Structures : array operations in c program
 
Programs
ProgramsPrograms
Programs
 
Double linked list
Double linked listDouble linked list
Double linked list
 
Ds
DsDs
Ds
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Data Structures Using C Practical File
Data Structures Using C Practical File Data Structures Using C Practical File
Data Structures Using C Practical File
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
C programs
C programsC programs
C programs
 
Sorting programs
Sorting programsSorting programs
Sorting programs
 
Ada file
Ada fileAda file
Ada file
 
C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
Data structure output 1
Data structure output 1Data structure output 1
Data structure output 1
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
ADA FILE
ADA FILEADA FILE
ADA FILE
 
Datastructures asignment
Datastructures asignmentDatastructures asignment
Datastructures asignment
 

Kürzlich hochgeladen

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 

Kürzlich hochgeladen (20)

NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

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; }