SlideShare a Scribd company logo
1 of 13
Arrays
Prepared By
Manthan Dhavne
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-Dimensional Array
◦ Two-Dimensional Array
◦ Multi-Dimensional Array
One-D Array
A type 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-D Array:
data_type identifier[length]; e.g: int marks[5];
oData _type: Data type of values to be stored in the array.
oIdentifier: Name of the array.
oLength: Number of elements.
0 1 2 3 4
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: int marks[5]={70,54,82,96,49};
oData _type: Data type of values to be stored in the array.
oIdentifier: Name of the array.
oLength: Number of elements
oList of values: Values to initialize the array. Initializing values
must be constant
70 54 82 96 49
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];
oData _type: Data type of values to be stored in the array.
oIdentifier: Name of the array.
oRows : # of Rows in the table of array.
oColumn : # of Columns in the table of array.
0,0 0,1 0,2
1,0 1,1 1,2
2,0 2,1 2,2
3,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 :
oThe elements of each row are enclosed within braces
and seperated by comma.
oAll rows are enclosed within braces.
oFor 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},
{95,3,41},
{77,6,53},
{84,59,62} } 12 5 22
95 3 41
77 6 53
84 59 62
Column
indexes
Row
indexes
0
2
1
3
10 2
Multidimensional Arrays
int matrix[10] [10];
for (i=0; i<10; i++)
for (j=0; j<10; j++)
{
matrix[i] [j] = i * j;
}
float mat[5] [5];
Multidimensional Arrays Illustration
0 1 2 3 4
0
1
2
3
4
0 1 2 3 4
0
1
2 7
3
4
int matrix[5] [5]; matrix[2] [1] = 7
0 1 2
0 1 2 3
1 4 5 6
2 7 8 9
3 10 11 12
int[][] array ={
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}};
Initializing of Multidimensional Arrays
To declare, create and initialize a multidimensional array.
For example,
int[][] array = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
{10, 11, 12}
};
This is equivalent to the following statements:
array[0][0] = 1; array[0][1] = 2; array[0][2] = 3;
array[1][0] = 4; array[1][1] = 5; array[1][2] = 6;
array[2][0] = 7; array[2][1] = 8; array[2][2] = 9;
array[3][0] = 10; array[3][1] = 11; array[3][2] = 12;
Thank you 

More Related Content

What's hot

What's hot (20)

Arrays Basics
Arrays BasicsArrays Basics
Arrays Basics
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Lecture 2a arrays
Lecture 2a arraysLecture 2a arrays
Lecture 2a arrays
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Array
ArrayArray
Array
 
Array in c#
Array in c#Array in c#
Array in c#
 
Array in c++
Array in c++Array in c++
Array in c++
 
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Array
ArrayArray
Array
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithmsLecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
 
One Dimensional Array
One Dimensional Array One Dimensional Array
One Dimensional Array
 
Data structures
Data structuresData structures
Data structures
 
Arrays In C
Arrays In CArrays In C
Arrays In C
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Basic array in c programming
Basic array in c programmingBasic array in c programming
Basic array in c programming
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
 

Similar to Arrays (20)

array-191103180006.pdf
array-191103180006.pdfarray-191103180006.pdf
array-191103180006.pdf
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional arrayArray Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
 
Array
ArrayArray
Array
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Arrays
ArraysArrays
Arrays
 
Array ppt
Array pptArray ppt
Array ppt
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 
Chapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdfChapter 4 (Part I) - Array and Strings.pdf
Chapter 4 (Part I) - Array and Strings.pdf
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
arrayppt.pptx
arrayppt.pptxarrayppt.pptx
arrayppt.pptx
 
Arrays
ArraysArrays
Arrays
 
2D Array
2D Array 2D Array
2D Array
 
Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional Arrays 1D and 2D , and multi dimensional
Arrays 1D and 2D , and multi dimensional
 
Arrays
ArraysArrays
Arrays
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
About Array
About ArrayAbout Array
About Array
 
Arrays accessing using for loops
Arrays accessing using for loopsArrays accessing using for loops
Arrays accessing using for loops
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Array
ArrayArray
Array
 

More from Manthan Dhavne

Improper integral of second kind
Improper integral of second kindImproper integral of second kind
Improper integral of second kindManthan Dhavne
 
Orthographic Projection
Orthographic ProjectionOrthographic Projection
Orthographic ProjectionManthan Dhavne
 
Maglev train & Josephson effect
Maglev train & Josephson effectMaglev train & Josephson effect
Maglev train & Josephson effectManthan Dhavne
 
Environmental legislation &amp; water pollution acts
Environmental legislation &amp; water pollution actsEnvironmental legislation &amp; water pollution acts
Environmental legislation &amp; water pollution actsManthan Dhavne
 
Global Postioning System
Global Postioning SystemGlobal Postioning System
Global Postioning SystemManthan Dhavne
 
Connector and switches
Connector and switchesConnector and switches
Connector and switchesManthan Dhavne
 

More from Manthan Dhavne (8)

Improper integral of second kind
Improper integral of second kindImproper integral of second kind
Improper integral of second kind
 
Orthographic Projection
Orthographic ProjectionOrthographic Projection
Orthographic Projection
 
Maglev train & Josephson effect
Maglev train & Josephson effectMaglev train & Josephson effect
Maglev train & Josephson effect
 
Environmental legislation &amp; water pollution acts
Environmental legislation &amp; water pollution actsEnvironmental legislation &amp; water pollution acts
Environmental legislation &amp; water pollution acts
 
Global Postioning System
Global Postioning SystemGlobal Postioning System
Global Postioning System
 
Connector and switches
Connector and switchesConnector and switches
Connector and switches
 
Proxemics
ProxemicsProxemics
Proxemics
 
Cochran Boiler
Cochran BoilerCochran Boiler
Cochran Boiler
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
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
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
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
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
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
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
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
 
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
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
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
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
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
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
★ 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
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
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
 
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
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 

Arrays

  • 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.
  • 4. Types of Arrays: ◦ One-Dimensional Array ◦ Two-Dimensional Array ◦ Multi-Dimensional Array
  • 5. One-D Array A type 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-D Array: data_type identifier[length]; e.g: int marks[5]; oData _type: Data type of values to be stored in the array. oIdentifier: Name of the array. oLength: Number of elements. 0 1 2 3 4 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: int marks[5]={70,54,82,96,49}; oData _type: Data type of values to be stored in the array. oIdentifier: Name of the array. oLength: Number of elements oList of values: Values to initialize the array. Initializing values must be constant 70 54 82 96 49
  • 7. 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]; oData _type: Data type of values to be stored in the array. oIdentifier: Name of the array. oRows : # of Rows in the table of array. oColumn : # of Columns in the table of array. 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2 3,0 3,1 3,2
  • 8. 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 : oThe elements of each row are enclosed within braces and seperated by comma. oAll rows are enclosed within braces. oFor number arrays, if all elements are not specified , the un specified elements are initialized by zero.
  • 9. Two-D array Intialization Syntax: int arr[4][3]={ {12,5,22}, {95,3,41}, {77,6,53}, {84,59,62} } 12 5 22 95 3 41 77 6 53 84 59 62 Column indexes Row indexes 0 2 1 3 10 2
  • 10. Multidimensional Arrays int matrix[10] [10]; for (i=0; i<10; i++) for (j=0; j<10; j++) { matrix[i] [j] = i * j; } float mat[5] [5];
  • 11. Multidimensional Arrays Illustration 0 1 2 3 4 0 1 2 3 4 0 1 2 3 4 0 1 2 7 3 4 int matrix[5] [5]; matrix[2] [1] = 7 0 1 2 0 1 2 3 1 4 5 6 2 7 8 9 3 10 11 12 int[][] array ={ {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}};
  • 12. Initializing of Multidimensional Arrays To declare, create and initialize a multidimensional array. For example, int[][] array = { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12} }; This is equivalent to the following statements: array[0][0] = 1; array[0][1] = 2; array[0][2] = 3; array[1][0] = 4; array[1][1] = 5; array[1][2] = 6; array[2][0] = 7; array[2][1] = 8; array[2][2] = 9; array[3][0] = 10; array[3][1] = 11; array[3][2] = 12;

Editor's Notes

  1. &amp;lt;number&amp;gt;