SlideShare a Scribd company logo
Arrays
 Array is a collection of similar type of data.
 Array stores multiple values of same type.
 Arrays are reference types.
 They are automatically of a predefined type System.Array
 Syntax:
 Datatype [] Array_name=new Data type[size];
 Data type- specifies what type of data storing into the array. Array type
can be value type or reference type.
 Array_name-Indicates name of the array
 new-It allocates memory to the array at runtime
 Size-Indicates how many elements storing into the array
 ex: int []a=new int[5];
 string []names=new string[3];
Arrays
 Assigning values to array
 1.Int []a=new int[4]
 a[0]=10
 a[1]=20
 a[2]=30 0 1 2 3
 a[3]=40
 2. Int []a=new int[4]{10,20,30,40}
 3.Int []a={10,20,30,40} //Dynamic allocation
 Accessing elements
a[0];
In arrays index starts from 0
If there is a mismatch between the declared size and the number of
initializes , a compile time error is generated.
10 20 30 40
Arrays
 members of System. Array
 sort() -It sorts array elements in ascending order
 System.Array.Sort(array name)
 reverse()-It arrange array elements in reverse order
 System.Array.Reverse(array name)
 copy() –It copies one Array elements into to another array
 System.Array.Copy(source array name, destination array
name, count)
 Length- It returns size of the array
 Rank-It returns dimension of the array
Multidimensional array
 A multidimensional array stores values in multiple rows and
columns.
 An array can have a maximum of 32 dimensions.
 Two types of multidimensional array
 Rectangular array
 Jagged array
Rectangular Array
 A multidimensional array where length of each row is fixed through
out the array.
 Syntax: Data type[,] array_name=
 new Data type[row_size, col_size]
 Creation:
int[,] matrix = new int[5,5];
 Accessing array elements:
matrix[0,1]=9;
 Initializing
 int[,] matrix = new int[,] { {0, 1}, {2, 3},
{4, 5} };
Jagged Arrays
 A jagged array is an array of arrays.
 The element with in the jagged array it self is an array.
 The arrays may be of different sizes.
 Definition requires specification of size for only the topmost array.
 Datytype [ ][ ] Array_name = new Datatpe[size][ ] ;
 Size indicates no of arrays storing into jagged array
 Creation:
int[][] myarr=new int[3][];
 Creating arrays in the jagged array,
myarr[1]= new int[3]{0,1,2};
 Accessing elements
myarr[0][1]=8;
 Accessing the length of row 0 myarr[0].Length
 Initializing
 int[][] myarr= new int[][] { new int[] {0,1}, new
int[] {3,4,5} };
Or simply int[][] myarr = { new int[] { 0, 1 }, new
int[] { 3, 4, 5 } };
Ad

More Related Content

Similar to Arrays.pptx (20)

intorduction to Arrays in java
intorduction to Arrays in javaintorduction to Arrays in java
intorduction to Arrays in java
Muthukumaran Subramanian
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
ARRAYS in java with in details presentation.ppt
ARRAYS in java with in details presentation.pptARRAYS in java with in details presentation.ppt
ARRAYS in java with in details presentation.ppt
AshokRachapalli1
 
Array
ArrayArray
Array
Rokonuzzaman Rony
 
ARRAYS.ppt
ARRAYS.pptARRAYS.ppt
ARRAYS.ppt
surajthakur474818
 
Array
ArrayArray
Array
Allah Ditta
 
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
imtiazalijoono
 
array-191103180006.pdf
array-191103180006.pdfarray-191103180006.pdf
array-191103180006.pdf
HEMAHEMS5
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
Sasideepa
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
KristinaBorooah
 
Arrays
ArraysArrays
Arrays
Trupti Agrawal
 
ARRAYSCPP.pptx
ARRAYSCPP.pptxARRAYSCPP.pptx
ARRAYSCPP.pptx
727822TUCS116MOHANKU
 
Arrays
ArraysArrays
Arrays
ViniVini48
 
Arrays
ArraysArrays
Arrays
Notre Dame of Midsayap College
 
Array in c
Array in cArray in c
Array in c
Harsh Bhanushali
 
Chyuuuuuuuuuuryyyyyyyyyyy123456789786341.pptx
Chyuuuuuuuuuuryyyyyyyyyyy123456789786341.pptxChyuuuuuuuuuuryyyyyyyyyyy123456789786341.pptx
Chyuuuuuuuuuuryyyyyyyyyyy123456789786341.pptx
RobertCarreonBula
 
Array
ArrayArray
Array
PreethyJemima
 
Arrays accessing using for loops
Arrays accessing using for loopsArrays accessing using for loops
Arrays accessing using for loops
sangrampatil81
 
Array
ArrayArray
Array
PRN USM
 
Class notes(week 4) on arrays and strings
Class notes(week 4) on arrays and stringsClass notes(week 4) on arrays and strings
Class notes(week 4) on arrays and strings
Kuntal Bhowmick
 

Recently uploaded (20)

Geometry maths presentation for begginers
Geometry maths presentation for begginersGeometry maths presentation for begginers
Geometry maths presentation for begginers
zrjacob283
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
GenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.aiGenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.ai
Inspirient
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story
ccctableauusergroup
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..
yuvarajreddy2002
 
Classification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptxClassification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptx
wencyjorda88
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia03 Daniel 2-notes.ppt seminario escatologia
03 Daniel 2-notes.ppt seminario escatologia
Alexander Romero Arosquipa
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
VKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptxVKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptx
Vinod Srivastava
 
VKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptxVKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptx
Vinod Srivastava
 
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
ThanushsaranS
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbbEDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
JessaMaeEvangelista2
 
Geometry maths presentation for begginers
Geometry maths presentation for begginersGeometry maths presentation for begginers
Geometry maths presentation for begginers
zrjacob283
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
C++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptxC++_OOPs_DSA1_Presentation_Template.pptx
C++_OOPs_DSA1_Presentation_Template.pptx
aquibnoor22079
 
GenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.aiGenAI for Quant Analytics: survey-analytics.ai
GenAI for Quant Analytics: survey-analytics.ai
Inspirient
 
LLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bertLLM finetuning for multiple choice google bert
LLM finetuning for multiple choice google bert
ChadapornK
 
04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story04302025_CCC TUG_DataVista: The Design Story
04302025_CCC TUG_DataVista: The Design Story
ccctableauusergroup
 
Flip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptxFlip flop presenation-Presented By Mubahir khan.pptx
Flip flop presenation-Presented By Mubahir khan.pptx
mubashirkhan45461
 
Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..Secure_File_Storage_Hybrid_Cryptography.pptx..
Secure_File_Storage_Hybrid_Cryptography.pptx..
yuvarajreddy2002
 
Classification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptxClassification_in_Machinee_Learning.pptx
Classification_in_Machinee_Learning.pptx
wencyjorda88
 
How iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost FundsHow iCode cybertech Helped Me Recover My Lost Funds
How iCode cybertech Helped Me Recover My Lost Funds
ireneschmid345
 
Cleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdfCleaned_Lecture 6666666_Simulation_I.pdf
Cleaned_Lecture 6666666_Simulation_I.pdf
alcinialbob1234
 
VKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptxVKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptx
Vinod Srivastava
 
VKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptxVKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptx
Vinod Srivastava
 
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
CTS EXCEPTIONSPrediction of Aluminium wire rod physical properties through AI...
ThanushsaranS
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
Adobe Analytics NOAM Central User Group April 2025 Agent AI: Uncovering the S...
gmuir1066
 
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbbEDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
EDU533 DEMO.pptxccccvbnjjkoo jhgggggbbbb
JessaMaeEvangelista2
 
Ad

Arrays.pptx

  • 1. Arrays  Array is a collection of similar type of data.  Array stores multiple values of same type.  Arrays are reference types.  They are automatically of a predefined type System.Array  Syntax:  Datatype [] Array_name=new Data type[size];  Data type- specifies what type of data storing into the array. Array type can be value type or reference type.  Array_name-Indicates name of the array  new-It allocates memory to the array at runtime  Size-Indicates how many elements storing into the array  ex: int []a=new int[5];  string []names=new string[3];
  • 2. Arrays  Assigning values to array  1.Int []a=new int[4]  a[0]=10  a[1]=20  a[2]=30 0 1 2 3  a[3]=40  2. Int []a=new int[4]{10,20,30,40}  3.Int []a={10,20,30,40} //Dynamic allocation  Accessing elements a[0]; In arrays index starts from 0 If there is a mismatch between the declared size and the number of initializes , a compile time error is generated. 10 20 30 40
  • 3. Arrays  members of System. Array  sort() -It sorts array elements in ascending order  System.Array.Sort(array name)  reverse()-It arrange array elements in reverse order  System.Array.Reverse(array name)  copy() –It copies one Array elements into to another array  System.Array.Copy(source array name, destination array name, count)  Length- It returns size of the array  Rank-It returns dimension of the array
  • 4. Multidimensional array  A multidimensional array stores values in multiple rows and columns.  An array can have a maximum of 32 dimensions.  Two types of multidimensional array  Rectangular array  Jagged array
  • 5. Rectangular Array  A multidimensional array where length of each row is fixed through out the array.  Syntax: Data type[,] array_name=  new Data type[row_size, col_size]  Creation: int[,] matrix = new int[5,5];  Accessing array elements: matrix[0,1]=9;  Initializing  int[,] matrix = new int[,] { {0, 1}, {2, 3}, {4, 5} };
  • 6. Jagged Arrays  A jagged array is an array of arrays.  The element with in the jagged array it self is an array.  The arrays may be of different sizes.  Definition requires specification of size for only the topmost array.  Datytype [ ][ ] Array_name = new Datatpe[size][ ] ;  Size indicates no of arrays storing into jagged array  Creation: int[][] myarr=new int[3][];  Creating arrays in the jagged array, myarr[1]= new int[3]{0,1,2};  Accessing elements myarr[0][1]=8;  Accessing the length of row 0 myarr[0].Length  Initializing  int[][] myarr= new int[][] { new int[] {0,1}, new int[] {3,4,5} }; Or simply int[][] myarr = { new int[] { 0, 1 }, new int[] { 3, 4, 5 } };