SlideShare una empresa de Scribd logo
1 de 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

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Binary Search
Binary SearchBinary Search
Binary Search
 
stack & queue
stack & queuestack & queue
stack & queue
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Arrays
ArraysArrays
Arrays
 
Two dimensional arrays
Two dimensional arraysTwo dimensional arrays
Two dimensional arrays
 
Stacks
StacksStacks
Stacks
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Unit 4 python -list methods
Unit 4   python -list methodsUnit 4   python -list methods
Unit 4 python -list methods
 
Array data structure
Array data structureArray data structure
Array data structure
 
Singly link list
Singly link listSingly link list
Singly link list
 
Arrays
ArraysArrays
Arrays
 
Python dictionary
Python   dictionaryPython   dictionary
Python dictionary
 
Strings in C
Strings in CStrings in C
Strings in C
 
One dimensional 2
One dimensional 2One dimensional 2
One dimensional 2
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Queue ppt
Queue pptQueue ppt
Queue ppt
 
Array operations
Array operationsArray operations
Array operations
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
Array in c++
Array in c++Array in c++
Array in c++
 

Destacado

Destacado (8)

Array in C
Array in CArray in C
Array in C
 
Arrays
ArraysArrays
Arrays
 
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 a 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
 
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
 
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
 
Beginning Scala Svcc 2009
Beginning Scala Svcc 2009Beginning Scala Svcc 2009
Beginning Scala Svcc 2009David Pollak
 

Similar a 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
 

Último

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
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
 
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
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
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
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
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
 
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
 
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
 
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
 
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
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 

Último (20)

Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
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
 
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
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.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
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
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
 
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
 
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...
 
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
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
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
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
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