SlideShare a Scribd company logo
1 of 23
SEMINAR  ON   ARRAYS UNDER THE GUIDENCE OF- Ms. PINKI MA’M PREPARED BY- SAURABH SHUKLA & SAURABH VYAS B.E. 2 nd  Yr.  1Vth Sem
11/01/11 ARRAYS INTRODUCTION  AND  CHARACTERISTICS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],TYPES ,[object Object],[object Object],[object Object],[object Object],[object Object]
11/01/11 DECLARATION OF ONE DIMENSIONAL ARRAY Data_type var_name[Expression] Data Type  is the type of elements to be stored in the array Var_name  is the name of the array like any  Other variables  Expression  specifies the number of elements to be stored  In array Example  int num[10];   Num[0] =data1 Num[1] =data2 Num[2] =data3 Num[3] =data4 Num[4] =data5 Num[5] =data6 Num[6] =data7 Num[7] =data8 Num[8] =data9 Num[9] =data10
11/01/11 ACCESSING ONE DIMENSIONAL ARRAY ELEMENTS #<Include<stdio.h> #include<conio.h> Void main()  {  Int a[10];  Clrscr();  Printf (“enter the array”); For (i=0;i<10;i++)  {  Scanf(“%d”,&a[i]); }   Printf(“the entered array is”); For(i=0;i<10;i++)  {  printf(“%d”,a[i]);} }   getch();  }   Arrray  declaration  Taking values from user Printing the values OUTPUT Enter the array 1 2 3 4 5 6 7 8 9 10 Entered array is 1 2 3 4 5 6 7 8 9 10
11/01/11 OPERATIONS  IN  ARRAY ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
11/01/11 ALGORITHM ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],INSERTION
11/01/11 INSERTION Int i,len,pos,num; Void main() {  int a[10]; Void insert (int a[ ],int,int,int); Printf(“enter integers to be read”); Scanf(“%d”,&len); Printf(:enter ur array”); For(i=0;1<len;i++) { scanf(“%d”,&a[i]); } Printf(:enter position”); Scanf(“%d”,&pos); --pos; Printf(:enter integer to be inserted”); Scanf(“%d”,&num); Insert(a,len,pos,num);} For(i=len;1pos;i--) {a[i+1])=a[i]; } A{pos]=num; Len ++; Printf(“new array is ”); For(i=0;i<len;i++) { printf(“%d”,&a[i]); }   } ORIGINAL ARRAY 1  2  3  4  5  6  7  8 HOW IT WORKS ENTER POSITION   4 ENTER NUM   9 DURING PROCESSING 1  2  3  ……..  4  5  6  7  8 NEW ARRAY 1  2  3  …9….  4  5  6  7  8 THE  ACTUAL 4 th  POSITION
11/01/11 ALGORITHM ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],DELETION
11/01/11 DELETION Int i,n; Void main() {   Int a[10],pos; Void delete(int a[ ],int,int); Printf(“enter no of elements in array”); Scanf(“%d”,&n); Printf(“enter ur array”); For(i=0;i<n;i++) Scanf(“%d”,&a[i]); Printf(:enter position”); Scanf(“%d”,&pos); --pos; delete(a[ ],pos,n);  Void delete(int a [ ],int pos,int n) {  int j item; Item =a[pos]; For(j=pos;j<n;j++) a[j]=a[j+1]; n=n-1;  } For(i=0;i<n;i++) printf(“%d”,&a[i]);  } HOW IT WORKS ORIGINAL ARRAY 1  2  3  4  5  6  7  8 ENTER POSITION   4 DURING PROCESSING 1  2  3  4  5  6  7  8 NEW ARRAY 1  2  3  5  6  7  8 THE  ACTUAL 4 th  POSITION
11/01/11 ALGORITHM Letr LB be the lower bound andUB be the  upper bound of linear array a 1. [initialize the counter]  Set I at lower bound LB  2. Repeat for i=LB to UB  [visit element]Display element a[i] [end of the loop] 3. EXIT  TRAVERSING
11/01/11 TRAVERSING AN ARRAY #include<stdio.h> Void main ( ) { Int i,n,a[10]; printf)(“enter length of the array”); Scanf(“%d”,&n); Printf(“enter ur array”); For(i=0;i<n;i++) Scanf(“%d”,&a [ i ]); Printf(“traversing the array”); For(i=0;i<n;i++) printf(“%d”,&a [ i ]); } OUTPUT 1 2 3 4 5 TRAVERSING THE ARRAY ENTER UR ARRAY 1  2  3  4  5  ENTER LENGTH OF ARRAY  5
11/01/11 MERGING OF THE TWO ARRAYS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
11/01/11 void main() { int a[10],b[10],c[10],i,j,k=0,l,m,n; cout<<&quot;Enter sizeof array1 and array2” ;    cin>>m>>n;    cout<<&quot;Enter elements of 1st:&quot;;  for(i=0;i<m;i++) {cin>>a[i];}  cout<<&quot;Elements of 2nd list:&quot;;  for(i=0;i<n;i++)  {cin>>b[i];}   for(i=0;i<m;i++)  {c[i]=a[i];}  for(j=0;j<n;j++)  {c[j+m]=b[j];}  for(i=0;i<(m+n);i++) {for(j=0;j<(m+n);j++) {if(c[i]<c[j]) {k=c[j];  c[j]=c[i]; c[i]=k; }}} cout<<&quot;New merged array :&quot;; for(i=0;i<(m+n);i++) {cout<<c[i]<<&quot;&quot;;} } PROGRAM OUTPUT Enter size of array1 and array2  5 6 Enter elements of 1 st: 5 9 16 50 80 Elements of 2 nd  list: 11 32 49 58 75 98 New merged array : 5 9 11 16 32 49 50 58 75 80 98
11/01/11 ALGORITHM SEARCHING ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
11/01/11 SEARCHING Int i,n; Void main() {   Int a[10],pos=-1,k; Printf(“enter no of elements in array”); Scanf(“%d”,&n); Printf(“enter ur array”); For(i=0;i<n;i++) Scanf(“%d”,&a[i]); Printf(:enter no. to be searched :”); Scanf(“%d”,&k);   For(j=0;j<n;j++) {if (k==a[j]) {pos=i; break;}  } If (pos>=0) printf(“%d is found in position %d”,k,pos+1); Else printf(“element does not exist”); getch();  } OUTPUT Enter no of elements in array: 6 Enter ur array: 10 20 30 40 50 60 Enter no to be searched : 50 50 is found in position 5 OUTPUT Enter no of elements in array: 6 Enter ur array: 10 20 30 40 50 60 Enter no to be searched : 45 Element does not exist
11/01/11 SORTING ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],TYPES 1.BUBBLE SORT  2.SELECTION SORT 3.INSERTION SORT  4.QUICK SORT  5.MEARGE SORT  etc.
11/01/11 SELECTION   SORTINNG ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
11/01/11 PROGRAM #include<stdio.h> void main() { int a[10],i,n,j,x; printf(&quot;enter the value of n  &quot;); scanf(&quot;%d&quot;,&n); printf(&quot;enter array  &quot;); for(i=0;i<n;i++) { scanf(&quot;%d&quot;,&a[i]);} printf(&quot; ur  unsorted array is  &quot;); for(i=0;i<n;i++) { printf(&quot;%d  &quot;,a[i]);} for(i=0;i<n;i++) {  for(j=0;j<n;j++) {  if(a[j]>a[i]) {  x=a[i]; a[i]=a[j]; a[j]=x;  }  } } printf(&quot; ur sorted  array  is &quot;); for(j=0;j<n;j++) {printf(&quot;%d  &quot;,a[j]);} } SELECTION SORTING
11/01/11 interchange 16 13 15 EXAMPLE ENTERED ARRAY a[0] a[1] a[2] a[3] a[4] 6 PASS 1 13 16 6 2 15 PASS 2 13 16 15 2 6 PASS 3  16 13 15 2 6 PASS 4 15 13 16 2 6 PASS 5 13 2 6 16 15 2
11/01/11 BUBBLE SORTING ,[object Object],[object Object],[object Object],[object Object],[object Object],EXAMPLE INITIAL ELEMENTS (without sorting) 11  15  2  13  6
11/01/11 EXAMPLE > 11 13 ENTERED ARRAY a[0] a[1] a[2] a[3] a[4] 6 PASS 1 6 13 15 11 2 PASS 2 13 6 15 2 11 PASS 3  11 13 15 2 6 PASS 4 13 11 15 2 6 RESULT 13 2 6 11 15 2 < > > > < > < < > < < < < < < 15
11/01/11 LIMITATIONS OF  LINEAR ARRAYS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
11/01/11 FROM  SAURABH SHUKLA  &  SAURABH  VYAS

More Related Content

What's hot (20)

concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
 
Strings Functions in C Programming
Strings Functions in C ProgrammingStrings Functions in C Programming
Strings Functions in C Programming
 
arrays in c
arrays in carrays in c
arrays in c
 
Arrays
ArraysArrays
Arrays
 
Python : Data Types
Python : Data TypesPython : Data Types
Python : Data Types
 
List in Python
List in PythonList in Python
List in Python
 
Arrays
ArraysArrays
Arrays
 
Array in C
Array in CArray in C
Array in C
 
Data structure Stack
Data structure StackData structure Stack
Data structure Stack
 
Python tuple
Python   tuplePython   tuple
Python tuple
 
C pointer
C pointerC pointer
C pointer
 
Array ppt
Array pptArray ppt
Array ppt
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Array
ArrayArray
Array
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
 
Arrays in python
Arrays in pythonArrays in python
Arrays in python
 
Python programming : Strings
Python programming : StringsPython programming : Strings
Python programming : Strings
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Single linked list
Single linked listSingle linked list
Single linked list
 

Viewers also liked

Dbs3024 biz trx week 2 double entry system
Dbs3024 biz trx week 2 double entry systemDbs3024 biz trx week 2 double entry system
Dbs3024 biz trx week 2 double entry systemStephen Ong
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : ArraysGagan Deep
 
Double entry system
Double entry systemDouble entry system
Double entry systemRaJesh Thakur
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 

Viewers also liked (6)

Dbs3024 biz trx week 2 double entry system
Dbs3024 biz trx week 2 double entry systemDbs3024 biz trx week 2 double entry system
Dbs3024 biz trx week 2 double entry system
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Double entry system
Double entry systemDouble entry system
Double entry system
 
Double entry systme
Double entry systmeDouble entry systme
Double entry systme
 
Double Entry
Double EntryDouble Entry
Double Entry
 
Array in c language
Array in c languageArray in c language
Array in c language
 

Similar to Array Presentation (EngineerBaBu.com)

Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manualnikshaikh786
 
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptxINDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptxAbhimanyuChaure
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arraysmaamir farooq
 
stacks and queues
stacks and queuesstacks and queues
stacks and queuesDurgaDeviCbit
 
SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfHimanshuKansal22
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updatedvrgokila
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7Kumar
 
DSA - Array.pptx
DSA - Array.pptxDSA - Array.pptx
DSA - Array.pptx11STEM2PGROUP1
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to ErlangCorrado Santoro
 
Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)mailmerk
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applicationsAhsan Mansiv
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File Harjinder Singh
 
Arrays
ArraysArrays
Arraysafzal pa
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009David Pollak
 

Similar to Array Presentation (EngineerBaBu.com) (20)

Sorting
SortingSorting
Sorting
 
Data structure lab manual
Data structure lab manualData structure lab manual
Data structure lab manual
 
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptxINDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptx
INDIAN INSTITUTE OF TECHNOLOGY KANPUR ESC 111M Lec12.pptx
 
Sorting
SortingSorting
Sorting
 
Data structures arrays
Data structures   arraysData structures   arrays
Data structures arrays
 
stacks and queues
stacks and queuesstacks and queues
stacks and queues
 
04 stacks
04 stacks04 stacks
04 stacks
 
SlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdfSlideSet_4_Arraysnew.pdf
SlideSet_4_Arraysnew.pdf
 
Array 31.8.2020 updated
Array 31.8.2020 updatedArray 31.8.2020 updated
Array 31.8.2020 updated
 
Data structure lecture7
Data structure lecture7Data structure lecture7
Data structure lecture7
 
Arrays
ArraysArrays
Arrays
 
DSA - Array.pptx
DSA - Array.pptxDSA - Array.pptx
DSA - Array.pptx
 
Introduction to Erlang
Introduction to ErlangIntroduction to Erlang
Introduction to Erlang
 
DAA Lab Work.docx
DAA Lab Work.docxDAA Lab Work.docx
DAA Lab Work.docx
 
05 queues
05 queues05 queues
05 queues
 
Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)Data structure and algorithm.(dsa)
Data structure and algorithm.(dsa)
 
Stack and its applications
Stack and its applicationsStack and its applications
Stack and its applications
 
Data Structures Practical File
Data Structures Practical File Data Structures Practical File
Data Structures Practical File
 
Arrays
ArraysArrays
Arrays
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009
 

Recently uploaded

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 

Recently uploaded (20)

Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 

Array Presentation (EngineerBaBu.com)

  • 1. SEMINAR ON ARRAYS UNDER THE GUIDENCE OF- Ms. PINKI MA’M PREPARED BY- SAURABH SHUKLA & SAURABH VYAS B.E. 2 nd Yr. 1Vth Sem
  • 2.
  • 3. 11/01/11 DECLARATION OF ONE DIMENSIONAL ARRAY Data_type var_name[Expression] Data Type is the type of elements to be stored in the array Var_name is the name of the array like any Other variables Expression specifies the number of elements to be stored In array Example int num[10]; Num[0] =data1 Num[1] =data2 Num[2] =data3 Num[3] =data4 Num[4] =data5 Num[5] =data6 Num[6] =data7 Num[7] =data8 Num[8] =data9 Num[9] =data10
  • 4. 11/01/11 ACCESSING ONE DIMENSIONAL ARRAY ELEMENTS #<Include<stdio.h> #include<conio.h> Void main() { Int a[10]; Clrscr(); Printf (“enter the array”); For (i=0;i<10;i++) { Scanf(“%d”,&a[i]); } Printf(“the entered array is”); For(i=0;i<10;i++) { printf(“%d”,a[i]);} } getch(); } Arrray declaration Taking values from user Printing the values OUTPUT Enter the array 1 2 3 4 5 6 7 8 9 10 Entered array is 1 2 3 4 5 6 7 8 9 10
  • 5.
  • 6.
  • 7. 11/01/11 INSERTION Int i,len,pos,num; Void main() { int a[10]; Void insert (int a[ ],int,int,int); Printf(“enter integers to be read”); Scanf(“%d”,&len); Printf(:enter ur array”); For(i=0;1<len;i++) { scanf(“%d”,&a[i]); } Printf(:enter position”); Scanf(“%d”,&pos); --pos; Printf(:enter integer to be inserted”); Scanf(“%d”,&num); Insert(a,len,pos,num);} For(i=len;1pos;i--) {a[i+1])=a[i]; } A{pos]=num; Len ++; Printf(“new array is ”); For(i=0;i<len;i++) { printf(“%d”,&a[i]); } } ORIGINAL ARRAY 1 2 3 4 5 6 7 8 HOW IT WORKS ENTER POSITION 4 ENTER NUM 9 DURING PROCESSING 1 2 3 …….. 4 5 6 7 8 NEW ARRAY 1 2 3 …9…. 4 5 6 7 8 THE ACTUAL 4 th POSITION
  • 8.
  • 9. 11/01/11 DELETION Int i,n; Void main() { Int a[10],pos; Void delete(int a[ ],int,int); Printf(“enter no of elements in array”); Scanf(“%d”,&n); Printf(“enter ur array”); For(i=0;i<n;i++) Scanf(“%d”,&a[i]); Printf(:enter position”); Scanf(“%d”,&pos); --pos; delete(a[ ],pos,n); Void delete(int a [ ],int pos,int n) { int j item; Item =a[pos]; For(j=pos;j<n;j++) a[j]=a[j+1]; n=n-1; } For(i=0;i<n;i++) printf(“%d”,&a[i]); } HOW IT WORKS ORIGINAL ARRAY 1 2 3 4 5 6 7 8 ENTER POSITION 4 DURING PROCESSING 1 2 3 4 5 6 7 8 NEW ARRAY 1 2 3 5 6 7 8 THE ACTUAL 4 th POSITION
  • 10. 11/01/11 ALGORITHM Letr LB be the lower bound andUB be the upper bound of linear array a 1. [initialize the counter] Set I at lower bound LB 2. Repeat for i=LB to UB [visit element]Display element a[i] [end of the loop] 3. EXIT TRAVERSING
  • 11. 11/01/11 TRAVERSING AN ARRAY #include<stdio.h> Void main ( ) { Int i,n,a[10]; printf)(“enter length of the array”); Scanf(“%d”,&n); Printf(“enter ur array”); For(i=0;i<n;i++) Scanf(“%d”,&a [ i ]); Printf(“traversing the array”); For(i=0;i<n;i++) printf(“%d”,&a [ i ]); } OUTPUT 1 2 3 4 5 TRAVERSING THE ARRAY ENTER UR ARRAY 1 2 3 4 5 ENTER LENGTH OF ARRAY 5
  • 12.
  • 13. 11/01/11 void main() { int a[10],b[10],c[10],i,j,k=0,l,m,n; cout<<&quot;Enter sizeof array1 and array2” ; cin>>m>>n; cout<<&quot;Enter elements of 1st:&quot;; for(i=0;i<m;i++) {cin>>a[i];} cout<<&quot;Elements of 2nd list:&quot;; for(i=0;i<n;i++) {cin>>b[i];} for(i=0;i<m;i++) {c[i]=a[i];} for(j=0;j<n;j++) {c[j+m]=b[j];} for(i=0;i<(m+n);i++) {for(j=0;j<(m+n);j++) {if(c[i]<c[j]) {k=c[j]; c[j]=c[i]; c[i]=k; }}} cout<<&quot;New merged array :&quot;; for(i=0;i<(m+n);i++) {cout<<c[i]<<&quot;&quot;;} } PROGRAM OUTPUT Enter size of array1 and array2 5 6 Enter elements of 1 st: 5 9 16 50 80 Elements of 2 nd list: 11 32 49 58 75 98 New merged array : 5 9 11 16 32 49 50 58 75 80 98
  • 14.
  • 15. 11/01/11 SEARCHING Int i,n; Void main() { Int a[10],pos=-1,k; Printf(“enter no of elements in array”); Scanf(“%d”,&n); Printf(“enter ur array”); For(i=0;i<n;i++) Scanf(“%d”,&a[i]); Printf(:enter no. to be searched :”); Scanf(“%d”,&k); For(j=0;j<n;j++) {if (k==a[j]) {pos=i; break;} } If (pos>=0) printf(“%d is found in position %d”,k,pos+1); Else printf(“element does not exist”); getch(); } OUTPUT Enter no of elements in array: 6 Enter ur array: 10 20 30 40 50 60 Enter no to be searched : 50 50 is found in position 5 OUTPUT Enter no of elements in array: 6 Enter ur array: 10 20 30 40 50 60 Enter no to be searched : 45 Element does not exist
  • 16.
  • 17.
  • 18. 11/01/11 PROGRAM #include<stdio.h> void main() { int a[10],i,n,j,x; printf(&quot;enter the value of n &quot;); scanf(&quot;%d&quot;,&n); printf(&quot;enter array &quot;); for(i=0;i<n;i++) { scanf(&quot;%d&quot;,&a[i]);} printf(&quot; ur unsorted array is &quot;); for(i=0;i<n;i++) { printf(&quot;%d &quot;,a[i]);} for(i=0;i<n;i++) { for(j=0;j<n;j++) { if(a[j]>a[i]) { x=a[i]; a[i]=a[j]; a[j]=x; } } } printf(&quot; ur sorted array is &quot;); for(j=0;j<n;j++) {printf(&quot;%d &quot;,a[j]);} } SELECTION SORTING
  • 19. 11/01/11 interchange 16 13 15 EXAMPLE ENTERED ARRAY a[0] a[1] a[2] a[3] a[4] 6 PASS 1 13 16 6 2 15 PASS 2 13 16 15 2 6 PASS 3 16 13 15 2 6 PASS 4 15 13 16 2 6 PASS 5 13 2 6 16 15 2
  • 20.
  • 21. 11/01/11 EXAMPLE > 11 13 ENTERED ARRAY a[0] a[1] a[2] a[3] a[4] 6 PASS 1 6 13 15 11 2 PASS 2 13 6 15 2 11 PASS 3 11 13 15 2 6 PASS 4 13 11 15 2 6 RESULT 13 2 6 11 15 2 < > > > < > < < > < < < < < < 15
  • 22.
  • 23. 11/01/11 FROM SAURABH SHUKLA & SAURABH VYAS