SlideShare a Scribd company logo
1 of 9
AllahDitta
Roll#1419(30716)
BScs Morning(6th)

 An array is a collection of variables of the same type
that are referred to by a common name
arrays can have one or more dimensions, although
the one-dimensional array is the
most common
ARRAY

 A one-dimensional array is a list of related variables.
Such lists are common in programming.
For example, you might use a one-dimensional array
to store the account numbers of the
active users on a network. Another array might store
the current batting averages for a
baseball team.
type[ ] array-name = new type[size];
For example:
int arr = new int[100]
One-Dimensional
Arrays

 If you come from a C or C++ background, pay special
attention to the way arrays are declared. Specifically, the
square brackets follow the type name, not the array name.
Here is an example. The following creates an int
array of ten elements and links it to an
array reference variable named sample.
int[] sample = new int[10];
One-Dimensional
Arrays

 class ArrayDemo {
static void Main() {
int[] sample = new int[10];
int i;
for(i = 0; i < 3; i = i+1)
sample[i] = i;
for(i = 0; i <3; i = i+1)
Console.WriteLine("sample[" + i + "]: " + sample[i]);
}
}
sample[0]: 0
sample[1]: 1
sample[2]: 2
Code One Dimensional
Array

 Arrays can be initialized when they are created.
general form for initializing a onedimensional array
type[ ] array-name = { val1, val2, val3, ..., valN };
Initialized One
Dimensional array

 The simplest form of the multidimensional array is
the 2-dimensional array. A 2-dimensional array is a
list of one-dimensional arrays.
 string [,] names
 Pay careful attention to the declaration. Notice that
the two dimensions are separated from
each other by a comma. In the first part of the
declaration, the syntax
[,]
Two-Dimensional
Arrays

 int [,] a = new int [3,4]
 {
 {0, 1, 2, 3} , /* initializers for row indexed by 0 */ {4,
5, 6, 7} , /* initializers for row indexed by 1 */ {8, 9,
10, 11} /* initializers for row indexed by 2 */
 };
Initialized Two
Dimensional Array

 class TwoD
 {
static void Main()
 {
int t, i;
int[,] table = new int[3, 4];
for(t=0; t < 3; ++t)
 {
for(i=0; i < 4; ++i)
 {
table[t,i] = (t*4)+i+1;
Console.Write(table[t,i] + " ");
}
Console.WriteLine();
}
}
}
Code Two Dimensional
Array

More Related Content

What's hot (20)

C++ programming (Array)
C++ programming (Array)C++ programming (Array)
C++ programming (Array)
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Array in (C) programing
Array in (C) programing Array in (C) programing
Array in (C) programing
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Arrays in c language
Arrays in c languageArrays in c language
Arrays in c language
 
Array
ArrayArray
Array
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Array in C
Array in CArray in C
Array in C
 
Array
ArrayArray
Array
 
Array in c
Array in cArray in c
Array in c
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Array
ArrayArray
Array
 
C programming , array 2020
C programming , array 2020C programming , array 2020
C programming , array 2020
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
ARRAYS
ARRAYSARRAYS
ARRAYS
 
Introduction to Arrays in C
Introduction to Arrays in CIntroduction to Arrays in C
Introduction to Arrays in C
 
Array in C
Array in CArray in C
Array in C
 

Similar to Array (20)

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
 
Lecture 15 - Array
Lecture 15 - ArrayLecture 15 - Array
Lecture 15 - Array
 
Programming in c arrays
Programming in c   arraysProgramming in c   arrays
Programming in c arrays
 
lec 2- array declaration and initialization.pptx
lec 2- array declaration and initialization.pptxlec 2- array declaration and initialization.pptx
lec 2- array declaration and initialization.pptx
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Arrays
ArraysArrays
Arrays
 
Algo>Arrays
Algo>ArraysAlgo>Arrays
Algo>Arrays
 
Arrays
ArraysArrays
Arrays
 
Computer programming 2 Lesson 13
Computer programming 2  Lesson 13Computer programming 2  Lesson 13
Computer programming 2 Lesson 13
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
 
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
 
Comp102 lec 8
Comp102   lec 8Comp102   lec 8
Comp102 lec 8
 
Arrays
ArraysArrays
Arrays
 
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
 
Arrays
ArraysArrays
Arrays
 
Array
ArrayArray
Array
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
7.basic array
7.basic array7.basic array
7.basic array
 
3.ArraysandPointers.pptx
3.ArraysandPointers.pptx3.ArraysandPointers.pptx
3.ArraysandPointers.pptx
 

Recently uploaded

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
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
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
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
 
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
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
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
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
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
 
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
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.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
 

Array

  • 2.   An array is a collection of variables of the same type that are referred to by a common name arrays can have one or more dimensions, although the one-dimensional array is the most common ARRAY
  • 3.   A one-dimensional array is a list of related variables. Such lists are common in programming. For example, you might use a one-dimensional array to store the account numbers of the active users on a network. Another array might store the current batting averages for a baseball team. type[ ] array-name = new type[size]; For example: int arr = new int[100] One-Dimensional Arrays
  • 4.   If you come from a C or C++ background, pay special attention to the way arrays are declared. Specifically, the square brackets follow the type name, not the array name. Here is an example. The following creates an int array of ten elements and links it to an array reference variable named sample. int[] sample = new int[10]; One-Dimensional Arrays
  • 5.   class ArrayDemo { static void Main() { int[] sample = new int[10]; int i; for(i = 0; i < 3; i = i+1) sample[i] = i; for(i = 0; i <3; i = i+1) Console.WriteLine("sample[" + i + "]: " + sample[i]); } } sample[0]: 0 sample[1]: 1 sample[2]: 2 Code One Dimensional Array
  • 6.   Arrays can be initialized when they are created. general form for initializing a onedimensional array type[ ] array-name = { val1, val2, val3, ..., valN }; Initialized One Dimensional array
  • 7.   The simplest form of the multidimensional array is the 2-dimensional array. A 2-dimensional array is a list of one-dimensional arrays.  string [,] names  Pay careful attention to the declaration. Notice that the two dimensions are separated from each other by a comma. In the first part of the declaration, the syntax [,] Two-Dimensional Arrays
  • 8.   int [,] a = new int [3,4]  {  {0, 1, 2, 3} , /* initializers for row indexed by 0 */ {4, 5, 6, 7} , /* initializers for row indexed by 1 */ {8, 9, 10, 11} /* initializers for row indexed by 2 */  }; Initialized Two Dimensional Array
  • 9.   class TwoD  { static void Main()  { int t, i; int[,] table = new int[3, 4]; for(t=0; t < 3; ++t)  { for(i=0; i < 4; ++i)  { table[t,i] = (t*4)+i+1; Console.Write(table[t,i] + " "); } Console.WriteLine(); } } } Code Two Dimensional Array