SlideShare a Scribd company logo
Arrays
Dincy R Arikkat
Christ College(Autonomous),Irinjalakuda
One-Dimensional Arrays
• A list of values with the same data type
that are stored using a single group
name (array name).
• Elements of the array are stored in
consecutive memory location.
• Only One dimension
• General array declaration statement:
data-type array-name[number-of-items];
• Example
float arr[SIZE];
One-Dimensional Arrays (cont.)
• Individual elements of the array can be accessed by
specifying the name of the array and the element's
index:
arr[3]
• Warning: indices assume values from 0 to number-of-
items -1 !!
One-Dimensional Arrays (cont.)
arr[0] arr[1] arr[2] arr[3] arr[4]
Skip over 3 elements to get the
starting location of element 4
The array name arr identifies the
starting location of the array
Start here
element 4
Some array terminology
• Size-No.of elements in an array is called the size of
the array.
• Type-The kind of values it can store.
• Array name-name of array
• Base or index address-memory location where the
first element of the array is located.
Some Array Terminology
mark[50]
mark[5]
mark[2]
mark[2] = 32;
Array name
Index - also called a subscript
- must be an int,
- or an expression that evaluates to an int
Indexed variable - also called an
element or subscripted variable
Note that "element" may refer to either a single indexed
variable in the array or the value of a single indexed variable.
Value of the indexed variable
- also called an element of the array
size
Memory representation
1st
eleme
nt
2nd
eleme
nt
3rd
eleme
nt
…… Nth
eleme
nt
Array[1]Array[0] Array[2] Array[n-1]
Example
Memory address calculation
• Address of A[I]=
Base Address + size * (I - Lower Bound)
• Normally Lower Bound is 0,In some programming
language it will differ.
Memory address calculation
Question
• Given an array int marks[]={99,67,85,32,48,55,52};
Calculate the address of marks[4],if the base address is
1000.
Solution
• Address of A[I]=
Base Address + size * (I - Lower Bound)
Here,
Base address=1000, I=4, Lower Bound=0
Size of Int=2
Marks[4]=1000+ 2*(4-0) = 1008
Question
• Suppose an array A[10 … 20] is stored in a memory
whose starting address is 4000.Find the address of
A[15]?
Solution
• Base address=4000
• I=15,Lower Bound=10
• Size-2
• Address of A[I]=B.A + size*(I-Lower
bound)
• Address of A[15]=4000+2*(15-10)
=4010
Thank You

More Related Content

What's hot

Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
narmadhakin
 
Arrays in c
Arrays in cArrays in c
Arrays in c
Jeeva Nanthini
 
structure and union
structure and unionstructure and union
structure and union
student
 
Arrays
ArraysArrays
Strings in C
Strings in CStrings in C
Strings in C
Kamal Acharya
 
Array in c++
Array in c++Array in c++
Array in c++
Mahesha Mano
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorial
Kuntal Bhowmick
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
eShikshak
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
Kamal Acharya
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Pavith Gunasekara
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
Mauryasuraj98
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in C
Arpana shree
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
Mazharul Islam
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
tanmaymodi4
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
Kamal Acharya
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
Harshita Yadav
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
Tasnima Hamid
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
Emertxe Information Technologies Pvt Ltd
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
Niloy Saha
 

What's hot (20)

Conditional and control statement
Conditional and control statementConditional and control statement
Conditional and control statement
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
structure and union
structure and unionstructure and union
structure and union
 
Arrays
ArraysArrays
Arrays
 
Strings in C
Strings in CStrings in C
Strings in C
 
Array in c++
Array in c++Array in c++
Array in c++
 
Command line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorialCommand line-arguments-in-java-tutorial
Command line-arguments-in-java-tutorial
 
Datatypes in python
Datatypes in pythonDatatypes in python
Datatypes in python
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Union in C programming
Union in C programmingUnion in C programming
Union in C programming
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
 
Enumerated data types in C
Enumerated data types in CEnumerated data types in C
Enumerated data types in C
 
Array in c programming
Array in c programmingArray in c programming
Array in c programming
 
Union in c language
Union  in c languageUnion  in c language
Union in c language
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 
Python programming : Classes objects
Python programming : Classes objectsPython programming : Classes objects
Python programming : Classes objects
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 

Similar to One Dimensional Array

Array in c
Array in cArray in c
Array in c
Harsh Bhanushali
 
ARRAY
ARRAYARRAY
ARRAY
ayush raj
 
Arrays
ArraysArrays
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
HarmanShergill5
 
Lecture 15 - Array
Lecture 15 - ArrayLecture 15 - Array
Lecture 15 - Array
Md. Imran Hossain Showrov
 
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.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
MamataAnilgod
 
Arrays accessing using for loops
Arrays accessing using for loopsArrays accessing using for loops
Arrays accessing using for loops
sangrampatil81
 
Arrays
ArraysArrays
Arrays
Neeru Mittal
 
Arrays
ArraysArrays
Arrays
ViniVini48
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
Ashim Lamichhane
 
Arrays_in_c++.pptx
Arrays_in_c++.pptxArrays_in_c++.pptx
Arrays_in_c++.pptx
MrMaster11
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
Sasideepa
 
array-191103180006.pdf
array-191103180006.pdfarray-191103180006.pdf
array-191103180006.pdf
HEMAHEMS5
 
Arrays
ArraysArrays
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
KirubelWondwoson1
 
Algo>Arrays
Algo>ArraysAlgo>Arrays
Algo>Arrays
Ain-ul-Moiz Khawaja
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
AAKANKSHA JAIN
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
DEEPAK948083
 

Similar to One Dimensional Array (20)

Array in c
Array in cArray in c
Array in c
 
ARRAY
ARRAYARRAY
ARRAY
 
Arrays
ArraysArrays
Arrays
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Lecture 15 - Array
Lecture 15 - ArrayLecture 15 - Array
Lecture 15 - Array
 
Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm Arrays in Data Structure and Algorithm
Arrays in Data Structure and Algorithm
 
Arrays
ArraysArrays
Arrays
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Arrays accessing using for loops
Arrays accessing using for loopsArrays accessing using for loops
Arrays accessing using for loops
 
Arrays
ArraysArrays
Arrays
 
Arrays
ArraysArrays
Arrays
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
 
Arrays_in_c++.pptx
Arrays_in_c++.pptxArrays_in_c++.pptx
Arrays_in_c++.pptx
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
 
array-191103180006.pdf
array-191103180006.pdfarray-191103180006.pdf
array-191103180006.pdf
 
Arrays
ArraysArrays
Arrays
 
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
 
Algo>Arrays
Algo>ArraysAlgo>Arrays
Algo>Arrays
 
OOPs with java
OOPs with javaOOPs with java
OOPs with java
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 

Recently uploaded

LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
RAHUL
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
History of Stoke Newington
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
Celine George
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
GeorgeMilliken2
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
sayalidalavi006
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
NgcHiNguyn25
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
TechSoup
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
Katrina Pritchard
 

Recently uploaded (20)

LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPLAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
The History of Stoke Newington Street Names
The History of Stoke Newington Street NamesThe History of Stoke Newington Street Names
The History of Stoke Newington Street Names
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17How to Make a Field Mandatory in Odoo 17
How to Make a Field Mandatory in Odoo 17
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
What is Digital Literacy? A guest blog from Andy McLaughlin, University of Ab...
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5Community pharmacy- Social and preventive pharmacy UNIT 5
Community pharmacy- Social and preventive pharmacy UNIT 5
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Life upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for studentLife upper-Intermediate B2 Workbook for student
Life upper-Intermediate B2 Workbook for student
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Walmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdfWalmart Business+ and Spark Good for Nonprofits.pdf
Walmart Business+ and Spark Good for Nonprofits.pdf
 
BBR 2024 Summer Sessions Interview Training
BBR  2024 Summer Sessions Interview TrainingBBR  2024 Summer Sessions Interview Training
BBR 2024 Summer Sessions Interview Training
 

One Dimensional Array