SlideShare a Scribd company logo
1 of 18
This PPT will helpful for your project and self study also.
What is Arrays ?
• An array is a group of consective memory locations with same name and data
type.
• Simple variable is a single memory location with unique name and a type. But
an Array is collection of different adjacent memory locations. All these
memory locations have one collective name and type.
• The memory locations in the array are known as elements of array. The total
number of elements in the array is called length.
• The elements of array is accessed with reference to its position in array, that is
call index or subscript.
Advantages / Uses of Arrays
⚫Arrays can store a large number of value with single name.
⚫Arrays are used to process many value easily and quickly.
⚫The values stored in an array can be sorted easily.
⚫The search process can be applied on arrays easily.
Types of Arrays:
⚫One-DimensionalArray
⚫Two-DimensionalArray
⚫Multi-DimensionalArray
One-D Array
Atype of array in which all elements are arranged in the form of a list is
known as 1-D array or single dimensional array or linear list.
Declaring 1-DArray:
data_type identifier[length]; e.g: int marks[5];
0 1
Data type of values to be stored in the array.
Name of the array.
Number of elements.
4
o Data _type:
o Identifier:
o Length:
2 3
int marks
One-D array Intialization
The process of assigning values to array elements at the time of array
declaration is called array initialization.
Syntax:
data_type identifier[length]={ List of values }; e.g: ,96,49};
o Data _type:
o Identifier:
o Length:
Data type of values to be stored in the array.
Name of the array.
Number of elements
o List of values: Values to initialize the array. Initializing values must be constant
i
7
n
0
t m
5
a4
r
k
s8
[5
2]={9
76
0,5 4
4
,9
82
Accessing element of array
⚫Individual Element:
Array_name[index];
⚫Using Loop:
int marks[5];
for(int i=0;i<=4;i++)
marks[i]=i;
Searching In Array
Searching is a process of finding the required data in the array. Searching
becomes more important when the length of the array is very large.
There are two techniques to searching elements in array as follows:
⚫
⚫
Sequential search
Binary search
Sequential Search
Sequential search is also known as linear or serial search. It follows the
following step to search a value in array.
⚫Visit the first element of array and compare its value with required value.
⚫If the value of array matches with the desired value, the search is complete.
⚫If the value of array does not match, move to next element an repeat same
process.
Binary Search
Binary search is a quicker method of searching for value in the array. Binary
search is very quick but it can only search an sorted array. It cannot be
applied on an unsorted array.
o It locates the middle element of array and compare with desired number.
o If they are equal, search is successful and the index of middle element is
returned.
o If they are not equal, it reduces the search to half of the array.
o If the search number is less than the middle element, it searches the first half of
array.
Otherwise it searches the second half of the array. The process continues until
the required number is found or loop completes without successful search.
Sorting Arrays
Sorting is a process of arranging the value of array in a particular order.
An array can be sorted in two order.
o Ascending Order
o Descending Order 12 25 33 37 48
48 37 33 25 12
Techniques Of Sorting Array
There are two techniques of sorting array:
o Selection Sort
o Bubble Sort
Selection Sort
Selection sort is a technique that sort an array. It selects an element in the
array and moves it to its proper position. Selection sort works as follows:
1. Find the minimum value in the list.
2. Swap it with value in the first position.
3. Sort the remainder of the list excluding the first value.
Bubble Sort
Bubble Sort is also known as exchange sort. It repeatedly visits
the array and compares two items at a time. It works as follows:
o Compare adjacent element. If the first is greater than the second,
swap them.
o Repeat this for each pair of adjacent element, starting with the first
two and ending with the last two. (at this point last element should
be greatest).
o Repeat the step for all elements except the last one.
o Keep repeating for one fewer element each time until there are no
pairs to compare.
Two-D Arrays
Two-D array can be considered as table that consists of rows and
columns. Each element in 2-D array is refered with the help of two
indexes. One index indicates row and second indicates the column.
Declaring 2-D Array:
Data_type Identifier[row][column];
e.g: int arr[4][3];
Data type of values to be stored in the
o Data _type:
o Identifier:
o Rows :
o Column :
Name of the array.
# of Rows in the table of array.
# of Columns in the table of arr
a0
,r0
ra y.
0,
1
0,2
1,0 1,1 1,2
2,0 2,1 2,2
a3y,.0 3,1 3,2
Two-D array Intialization
The two-D array can also be initialized at the time of declaration.
Initialization is performed by assigning the initial values in braces
seperated by commas.
Some important points :
o The elements of each row are enclosed within braces and seperated by
comma.
o All rows are enclosed within braces.
o For number arrays, if all elements are not specified , the un specified
elements are initialized by zero.
Two-D array Intialization
Syntax:
int arr[4][3]={ {12,5,22},
12 5 22
95 3 41
77 6 53
84 59 62
Column
indexe{s95,3,41},
{77,6,53},
Row
indexes
0
{84,59,62} }1
2
3
1
0 2
arrayppt.pptx

More Related Content

Similar to arrayppt.pptx (20)

Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
 
Unit 4
Unit 4Unit 4
Unit 4
 
Array.ppt
Array.pptArray.ppt
Array.ppt
 
array.ppt
array.pptarray.ppt
array.ppt
 
Array
ArrayArray
Array
 
unit 2.pptx
unit 2.pptxunit 2.pptx
unit 2.pptx
 
Arrays in C.pptx
Arrays in C.pptxArrays in C.pptx
Arrays in C.pptx
 
arrays in c
arrays in carrays in c
arrays in c
 
Arrays accessing using for loops
Arrays accessing using for loopsArrays accessing using for loops
Arrays accessing using for loops
 
Data Structure
Data StructureData Structure
Data Structure
 
Array in c
Array in cArray in c
Array in c
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Acm aleppo cpc training seventh session
Acm aleppo cpc training seventh sessionAcm aleppo cpc training seventh session
Acm aleppo cpc training seventh session
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
DSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notesDSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notes
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada ReddyDatastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
 
arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Unit 2 linear data structures
Unit 2   linear data structuresUnit 2   linear data structures
Unit 2 linear data structures
 

More from shivas379526

FDP Prrgramme Future Institute of Managment Studies Bareilly.pptx
FDP Prrgramme Future Institute of Managment Studies Bareilly.pptxFDP Prrgramme Future Institute of Managment Studies Bareilly.pptx
FDP Prrgramme Future Institute of Managment Studies Bareilly.pptxshivas379526
 
FACULTY DEVELOPMENT PROGRAME BY DR. ELLOZY
FACULTY DEVELOPMENT  PROGRAME BY DR. ELLOZYFACULTY DEVELOPMENT  PROGRAME BY DR. ELLOZY
FACULTY DEVELOPMENT PROGRAME BY DR. ELLOZYshivas379526
 
Number-Systems presentation of the mathematics
Number-Systems presentation of the mathematicsNumber-Systems presentation of the mathematics
Number-Systems presentation of the mathematicsshivas379526
 
Story of Number.ppt
Story of Number.pptStory of Number.ppt
Story of Number.pptshivas379526
 
function of C.pptx
function of C.pptxfunction of C.pptx
function of C.pptxshivas379526
 
Specific_Learning_Disabilities
Specific_Learning_DisabilitiesSpecific_Learning_Disabilities
Specific_Learning_Disabilitiesshivas379526
 

More from shivas379526 (8)

FDP Prrgramme Future Institute of Managment Studies Bareilly.pptx
FDP Prrgramme Future Institute of Managment Studies Bareilly.pptxFDP Prrgramme Future Institute of Managment Studies Bareilly.pptx
FDP Prrgramme Future Institute of Managment Studies Bareilly.pptx
 
FACULTY DEVELOPMENT PROGRAME BY DR. ELLOZY
FACULTY DEVELOPMENT  PROGRAME BY DR. ELLOZYFACULTY DEVELOPMENT  PROGRAME BY DR. ELLOZY
FACULTY DEVELOPMENT PROGRAME BY DR. ELLOZY
 
Number-Systems presentation of the mathematics
Number-Systems presentation of the mathematicsNumber-Systems presentation of the mathematics
Number-Systems presentation of the mathematics
 
HCF and LCM.pptx
HCF and LCM.pptxHCF and LCM.pptx
HCF and LCM.pptx
 
Story of Number.ppt
Story of Number.pptStory of Number.ppt
Story of Number.ppt
 
function of C.pptx
function of C.pptxfunction of C.pptx
function of C.pptx
 
array Details
array Detailsarray Details
array Details
 
Specific_Learning_Disabilities
Specific_Learning_DisabilitiesSpecific_Learning_Disabilities
Specific_Learning_Disabilities
 

Recently uploaded

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 

arrayppt.pptx

  • 1. This PPT will helpful for your project and self study also.
  • 2. What is Arrays ? • An array is a group of consective memory locations with same name and data type. • Simple variable is a single memory location with unique name and a type. But an Array is collection of different adjacent memory locations. All these memory locations have one collective name and type. • The memory locations in the array are known as elements of array. The total number of elements in the array is called length. • The elements of array is accessed with reference to its position in array, that is call index or subscript.
  • 3. Advantages / Uses of Arrays ⚫Arrays can store a large number of value with single name. ⚫Arrays are used to process many value easily and quickly. ⚫The values stored in an array can be sorted easily. ⚫The search process can be applied on arrays easily.
  • 5. One-D Array Atype of array in which all elements are arranged in the form of a list is known as 1-D array or single dimensional array or linear list. Declaring 1-DArray: data_type identifier[length]; e.g: int marks[5]; 0 1 Data type of values to be stored in the array. Name of the array. Number of elements. 4 o Data _type: o Identifier: o Length: 2 3 int marks
  • 6. One-D array Intialization The process of assigning values to array elements at the time of array declaration is called array initialization. Syntax: data_type identifier[length]={ List of values }; e.g: ,96,49}; o Data _type: o Identifier: o Length: Data type of values to be stored in the array. Name of the array. Number of elements o List of values: Values to initialize the array. Initializing values must be constant i 7 n 0 t m 5 a4 r k s8 [5 2]={9 76 0,5 4 4 ,9 82
  • 7. Accessing element of array ⚫Individual Element: Array_name[index]; ⚫Using Loop: int marks[5]; for(int i=0;i<=4;i++) marks[i]=i;
  • 8. Searching In Array Searching is a process of finding the required data in the array. Searching becomes more important when the length of the array is very large. There are two techniques to searching elements in array as follows: ⚫ ⚫ Sequential search Binary search
  • 9. Sequential Search Sequential search is also known as linear or serial search. It follows the following step to search a value in array. ⚫Visit the first element of array and compare its value with required value. ⚫If the value of array matches with the desired value, the search is complete. ⚫If the value of array does not match, move to next element an repeat same process.
  • 10. Binary Search Binary search is a quicker method of searching for value in the array. Binary search is very quick but it can only search an sorted array. It cannot be applied on an unsorted array. o It locates the middle element of array and compare with desired number. o If they are equal, search is successful and the index of middle element is returned. o If they are not equal, it reduces the search to half of the array. o If the search number is less than the middle element, it searches the first half of array. Otherwise it searches the second half of the array. The process continues until the required number is found or loop completes without successful search.
  • 11. Sorting Arrays Sorting is a process of arranging the value of array in a particular order. An array can be sorted in two order. o Ascending Order o Descending Order 12 25 33 37 48 48 37 33 25 12
  • 12. Techniques Of Sorting Array There are two techniques of sorting array: o Selection Sort o Bubble Sort
  • 13. Selection Sort Selection sort is a technique that sort an array. It selects an element in the array and moves it to its proper position. Selection sort works as follows: 1. Find the minimum value in the list. 2. Swap it with value in the first position. 3. Sort the remainder of the list excluding the first value.
  • 14. Bubble Sort Bubble Sort is also known as exchange sort. It repeatedly visits the array and compares two items at a time. It works as follows: o Compare adjacent element. If the first is greater than the second, swap them. o Repeat this for each pair of adjacent element, starting with the first two and ending with the last two. (at this point last element should be greatest). o Repeat the step for all elements except the last one. o Keep repeating for one fewer element each time until there are no pairs to compare.
  • 15. Two-D Arrays Two-D array can be considered as table that consists of rows and columns. Each element in 2-D array is refered with the help of two indexes. One index indicates row and second indicates the column. Declaring 2-D Array: Data_type Identifier[row][column]; e.g: int arr[4][3]; Data type of values to be stored in the o Data _type: o Identifier: o Rows : o Column : Name of the array. # of Rows in the table of array. # of Columns in the table of arr a0 ,r0 ra y. 0, 1 0,2 1,0 1,1 1,2 2,0 2,1 2,2 a3y,.0 3,1 3,2
  • 16. Two-D array Intialization The two-D array can also be initialized at the time of declaration. Initialization is performed by assigning the initial values in braces seperated by commas. Some important points : o The elements of each row are enclosed within braces and seperated by comma. o All rows are enclosed within braces. o For number arrays, if all elements are not specified , the un specified elements are initialized by zero.
  • 17. Two-D array Intialization Syntax: int arr[4][3]={ {12,5,22}, 12 5 22 95 3 41 77 6 53 84 59 62 Column indexe{s95,3,41}, {77,6,53}, Row indexes 0 {84,59,62} }1 2 3 1 0 2