SlideShare ist ein Scribd-Unternehmen logo
1 von 6
Downloaden Sie, um offline zu lesen
ARRAYS IN C++
1 | P a g e
ARRAY:
Arrays are used to store multiple values in a single variable, instead of declaring separate
variables for each value.
They are used to store similar type of elements; the data type must be same for all the
elements.
They can be used to store collection of primitive data types such as int, float, double, char, etc.
PURPOSE OF ARRAY:
We can use normal variables (x, y, z) when we have a small number of objects, but if we want
to store many instances, it becomes difficult to manage them with normal variables. The idea of
an array is to represent many instances in one variable.
DECLARING AN ARRAY:
• Define the variable type.
• Specify the name of the array followed by square brackets.
• Specify the number of elements it should store/array size.
There are various ways in which we can declare an array. It can be done by specifying its type
and size, by initializing it or both.
1. ARRAY DECLARATION BY SPECIFYING SIZE:
2. ARRAY DECLARATION BY INITIALIZING ELEMENTS:
3. ARRAY DECLARATION BY SPECIFYING SIZE AND INITIALIZING ELEMENTS:
int array [10];
int array [10];
int array [6] = {10, 20, 30, 40}
OR
int n = 10;
int array [n];
ARRAYS IN C++
2 | P a g e
NOTE:
• The size and type of arrays cannot be changed after its declaration.
• The arraySize must be an integer constant greater than zero and type can be any valid
C++ data type.
SYNTAX:
FOR EXAMPLE,
• Here, we declared an array, value, of floating-point type and size 5. It can hold 5
floating-point values.
• We have now declared a variable that holds an array of four strings.
ACCESSING ARRAY ELEMENTS:
• Array elements are accessed by using an integer index.
• Array index starts with 0 and goes till size of array minus 1.
• An element is accessed by indexing the array name.
• This is done by placing the index of the element within square brackets after the name
of the array.
dataType arrayName [arraySize];
float value [5];
string cars [4] = {"Vitz", "BMW", "Toyota", "Surf"};
ARRAYS IN C++
3 | P a g e
EXPLANATION:
• Suppose an array “box” is declared, as below. The first element is box [0], second
element is box [1] and so on.
• Arrays have 0 as the first index, not 1. In this example, box [0] is the first element.
• If the size of an array is n, to access the last element, (n-1) index is used. In this
example, box [4] is the last element.
• The number of values between braces { } cannot be larger than the number of elements
that we declare for the array between square brackets [ ].
• In example above;
box [0] is equal to 10
box [1] is equal to 20
box [2] is equal to 35
box [3] is equal to 15
box [4] is equal to 25
box [0] box [1] box [2] box [3] box [4]
box [0] box [1] box [2] box [3] box [4]
10 20 35 15 25
ARRAYS IN C++
4 | P a g e
EXAMPLE PROGRAM-1:
A program printing the number of pancakes in a carton/box.
CODE FOR THE PROGRAM:
OUTPUT:
#include <iostream>
using namespace std;
int main()
{ int box [5] = {10,20,35,15,25};
cout<< "Box 1 has "<<box[0]<<" pancakes" <<endl
<<"Box 2 has " <<box[1] <<" pancakes" <<endl
<<"Box 3 has " <<box[2] <<" pancakes" <<endl
<<"Box 4 has " <<box[3] <<" pancakes" <<endl
<<"Box 5 has " <<box[4] <<" pancakes";
return 0;
}
ARRAYS IN C++
5 | P a g e
EXAMPLE PROGRAM-2:
C++ program to store and calculate the sum of 5 numbers entered by the user using arrays.
CODE FOR THE PROGRAM:
OUTPUT:
MULTIDIMENSIONAL ARRAYS:
• Multidimensional arrays can be described as "arrays of arrays".
• Multidimensional arrays are not limited to two indices (i.e., two dimensions). They can
contain as many indices as needed.
• For example, a bi-dimensional array can be imagined as a two-dimensional table made
of elements, all of them hold same type of elements.
SYNTAX:
data_type array_name[size1][size2]....[sizeN];
ARRAYS IN C++
6 | P a g e
EXPLANATION:
Table represents a bi-dimensional array of 3 per 5 elements of type int.
For example, the way to reference the second element vertically and fourth horizontally in an
expression would be:
ADVANTAGES OF AN ARRAY IN C/C++:
1. Random access of elements using array index.
2. Use of less line of code as it creates a single array of multiple elements.
3. Easy access to all the elements.
4. Traversal through the array becomes easy using a single loop.
5. Sorting becomes easy as it can be accomplished by writing less line of code.
DISADVANTAGES OF AN ARRAY IN C/C++:
1. Allows a fixed number of elements to be entered which is decided at the time of
declaration.
2. Insertion and deletion of elements can be costly since the elements are needed to be
managed in accordance with the new memory allocation.
Table [1][3]

Weitere ähnliche Inhalte

Was ist angesagt?

Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examples
greatqadirgee4u
 

Was ist angesagt? (20)

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
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Abstract data types (adt) intro to data structure part 2
Abstract data types (adt)   intro to data structure part 2Abstract data types (adt)   intro to data structure part 2
Abstract data types (adt) intro to data structure part 2
 
Linked list
Linked listLinked list
Linked list
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Queues
QueuesQueues
Queues
 
Queues
QueuesQueues
Queues
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Stacks Implementation and Examples
Stacks Implementation and ExamplesStacks Implementation and Examples
Stacks Implementation and Examples
 
Linked List
Linked ListLinked List
Linked List
 
Primitive data types in java
Primitive data types in javaPrimitive data types in java
Primitive data types in java
 
array of object pointer in c++
array of object pointer in c++array of object pointer in c++
array of object pointer in c++
 
Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)Computer Science-Data Structures :Abstract DataType (ADT)
Computer Science-Data Structures :Abstract DataType (ADT)
 
Circular queue
Circular queueCircular queue
Circular queue
 
Sparse matrix and its representation data structure
Sparse matrix and its representation data structureSparse matrix and its representation data structure
Sparse matrix and its representation data structure
 
Data structure using c++
Data structure using c++Data structure using c++
Data structure using c++
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Pointers
PointersPointers
Pointers
 

Ähnlich wie Arrays in C++

Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
dfsdg3
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
Sasideepa
 
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
teddiyfentaw
 

Ähnlich wie Arrays in C++ (20)

ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
 
Arrays
ArraysArrays
Arrays
 
Module1_arrays.pptx
Module1_arrays.pptxModule1_arrays.pptx
Module1_arrays.pptx
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.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
 
Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
 
PPt. on An _Array in C
PPt. on An _Array in CPPt. on An _Array in C
PPt. on An _Array in C
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Arrays
ArraysArrays
Arrays
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
Arrays
ArraysArrays
Arrays
 
Arrays.pptx
 Arrays.pptx Arrays.pptx
Arrays.pptx
 
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
5 ARRAYS AND STRINGSjiuojhiooioiiouioi.pptx
 
Arrays declartion and initialization
Arrays declartion and initializationArrays declartion and initialization
Arrays declartion and initialization
 
Arrays in C
Arrays in CArrays in C
Arrays in C
 
arrays.docx
arrays.docxarrays.docx
arrays.docx
 
Unit ii data structure-converted
Unit  ii data structure-convertedUnit  ii data structure-converted
Unit ii data structure-converted
 

Mehr von Maliha Mehr

Mehr von Maliha Mehr (20)

Types of bonds in brick masonry
Types of bonds in brick masonryTypes of bonds in brick masonry
Types of bonds in brick masonry
 
Interlocking Bricks
Interlocking BricksInterlocking Bricks
Interlocking Bricks
 
Types of Concrete
Types of ConcreteTypes of Concrete
Types of Concrete
 
Types of Paint with Application
Types of Paint with ApplicationTypes of Paint with Application
Types of Paint with Application
 
Types of deep foundation
Types of deep foundationTypes of deep foundation
Types of deep foundation
 
Recursion in C++
Recursion in C++Recursion in C++
Recursion in C++
 
Labor Problems, Their Prevention and Settlement
Labor Problems, Their Prevention and Settlement Labor Problems, Their Prevention and Settlement
Labor Problems, Their Prevention and Settlement
 
Buoyancy and Flotation
Buoyancy and FlotationBuoyancy and Flotation
Buoyancy and Flotation
 
Rotameter
Rotameter Rotameter
Rotameter
 
Rectangular and Circular underground water tank
Rectangular and Circular underground water tank Rectangular and Circular underground water tank
Rectangular and Circular underground water tank
 
Concrete blocks and their types
Concrete blocks and their typesConcrete blocks and their types
Concrete blocks and their types
 
Types of Stairs
Types of StairsTypes of Stairs
Types of Stairs
 
Geological Subsurface Maps
Geological Subsurface MapsGeological Subsurface Maps
Geological Subsurface Maps
 
Subsurface Mapping
Subsurface MappingSubsurface Mapping
Subsurface Mapping
 
Seismic Refraction Test
Seismic Refraction TestSeismic Refraction Test
Seismic Refraction Test
 
Topography and Topographical Maps
Topography and Topographical Maps Topography and Topographical Maps
Topography and Topographical Maps
 
Metamorphic rocks
Metamorphic rocks Metamorphic rocks
Metamorphic rocks
 
HVAC System (Heating, Ventilation and Air Conditioning)
HVAC System (Heating, Ventilation and Air Conditioning)HVAC System (Heating, Ventilation and Air Conditioning)
HVAC System (Heating, Ventilation and Air Conditioning)
 
Issues arising due to lack of project management
Issues arising due to lack of project managementIssues arising due to lack of project management
Issues arising due to lack of project management
 
Project Management Training
Project Management TrainingProject Management Training
Project Management Training
 

Kürzlich hochgeladen

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Kürzlich hochgeladen (20)

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank  Design by Working Stress - IS Method.pdfIntze Overhead Water Tank  Design by Working Stress - IS Method.pdf
Intze Overhead Water Tank Design by Working Stress - IS Method.pdf
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 

Arrays in C++

  • 1. ARRAYS IN C++ 1 | P a g e ARRAY: Arrays are used to store multiple values in a single variable, instead of declaring separate variables for each value. They are used to store similar type of elements; the data type must be same for all the elements. They can be used to store collection of primitive data types such as int, float, double, char, etc. PURPOSE OF ARRAY: We can use normal variables (x, y, z) when we have a small number of objects, but if we want to store many instances, it becomes difficult to manage them with normal variables. The idea of an array is to represent many instances in one variable. DECLARING AN ARRAY: • Define the variable type. • Specify the name of the array followed by square brackets. • Specify the number of elements it should store/array size. There are various ways in which we can declare an array. It can be done by specifying its type and size, by initializing it or both. 1. ARRAY DECLARATION BY SPECIFYING SIZE: 2. ARRAY DECLARATION BY INITIALIZING ELEMENTS: 3. ARRAY DECLARATION BY SPECIFYING SIZE AND INITIALIZING ELEMENTS: int array [10]; int array [10]; int array [6] = {10, 20, 30, 40} OR int n = 10; int array [n];
  • 2. ARRAYS IN C++ 2 | P a g e NOTE: • The size and type of arrays cannot be changed after its declaration. • The arraySize must be an integer constant greater than zero and type can be any valid C++ data type. SYNTAX: FOR EXAMPLE, • Here, we declared an array, value, of floating-point type and size 5. It can hold 5 floating-point values. • We have now declared a variable that holds an array of four strings. ACCESSING ARRAY ELEMENTS: • Array elements are accessed by using an integer index. • Array index starts with 0 and goes till size of array minus 1. • An element is accessed by indexing the array name. • This is done by placing the index of the element within square brackets after the name of the array. dataType arrayName [arraySize]; float value [5]; string cars [4] = {"Vitz", "BMW", "Toyota", "Surf"};
  • 3. ARRAYS IN C++ 3 | P a g e EXPLANATION: • Suppose an array “box” is declared, as below. The first element is box [0], second element is box [1] and so on. • Arrays have 0 as the first index, not 1. In this example, box [0] is the first element. • If the size of an array is n, to access the last element, (n-1) index is used. In this example, box [4] is the last element. • The number of values between braces { } cannot be larger than the number of elements that we declare for the array between square brackets [ ]. • In example above; box [0] is equal to 10 box [1] is equal to 20 box [2] is equal to 35 box [3] is equal to 15 box [4] is equal to 25 box [0] box [1] box [2] box [3] box [4] box [0] box [1] box [2] box [3] box [4] 10 20 35 15 25
  • 4. ARRAYS IN C++ 4 | P a g e EXAMPLE PROGRAM-1: A program printing the number of pancakes in a carton/box. CODE FOR THE PROGRAM: OUTPUT: #include <iostream> using namespace std; int main() { int box [5] = {10,20,35,15,25}; cout<< "Box 1 has "<<box[0]<<" pancakes" <<endl <<"Box 2 has " <<box[1] <<" pancakes" <<endl <<"Box 3 has " <<box[2] <<" pancakes" <<endl <<"Box 4 has " <<box[3] <<" pancakes" <<endl <<"Box 5 has " <<box[4] <<" pancakes"; return 0; }
  • 5. ARRAYS IN C++ 5 | P a g e EXAMPLE PROGRAM-2: C++ program to store and calculate the sum of 5 numbers entered by the user using arrays. CODE FOR THE PROGRAM: OUTPUT: MULTIDIMENSIONAL ARRAYS: • Multidimensional arrays can be described as "arrays of arrays". • Multidimensional arrays are not limited to two indices (i.e., two dimensions). They can contain as many indices as needed. • For example, a bi-dimensional array can be imagined as a two-dimensional table made of elements, all of them hold same type of elements. SYNTAX: data_type array_name[size1][size2]....[sizeN];
  • 6. ARRAYS IN C++ 6 | P a g e EXPLANATION: Table represents a bi-dimensional array of 3 per 5 elements of type int. For example, the way to reference the second element vertically and fourth horizontally in an expression would be: ADVANTAGES OF AN ARRAY IN C/C++: 1. Random access of elements using array index. 2. Use of less line of code as it creates a single array of multiple elements. 3. Easy access to all the elements. 4. Traversal through the array becomes easy using a single loop. 5. Sorting becomes easy as it can be accomplished by writing less line of code. DISADVANTAGES OF AN ARRAY IN C/C++: 1. Allows a fixed number of elements to be entered which is decided at the time of declaration. 2. Insertion and deletion of elements can be costly since the elements are needed to be managed in accordance with the new memory allocation. Table [1][3]