SlideShare una empresa de Scribd logo
1 de 33
ARRAY
Tejas Patel
Harekrushna Patel
Page 1
Content…
•
•
•
•

What are arrays?
Types of arrays
Single dimensional array
Multi dimensional array

Page 2
What are Arrays?
• Array is a data structure, which provides the facility to
store a collection of data of same type under single
variable name.

• It is a group of consecutive memory locations having same
name and type.

Page 3
Types
• One dimensional
• Multi dimensional

Page 4
Single Dimensional Array
• Element specified by single subscript
• Array declaration is made by specifying the data type, it’s
name and the number of space (size) so that the computer
may reserve the appropriate amount of memory.
Syntax
type array_name [ size ]

Base
type of
array

Name of No. of elements that can be
array
stored: Can be a integer
value without the sign

Page 5
Single dimensional Array Working
When user inputting data in array
i=0
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

a[0]

a[1]

a[2]

a[3]

a[4]
Page 6
Single dimensional Array Working
When user inputting data in array
i=0
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

a[0]

a[1]

a[2]

a[3]

a[4]
Page 7
Single dimensional Array Working
When user inputting data in array
i=0
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

a[0]

a[1]

a[2]

a[3]

a[4]
Page 8
Single dimensional Array Working
When user inputting data in array

for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}
i=1

5

a[0]

a[1]

a[2]

a[3]

a[4]
Page 9
Single dimensional Array Working
When user inputting data in array
i=1
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

a[0]

a[1]

a[2]

a[3]

a[4]
Page 10
Single dimensional Array Working
When user inputting data in array
i=1
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

a[0]

a[1]

a[2]

a[3]

a[4]
Page 11
Single dimensional Array Working
When user inputting data in array

for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}
i=2

5

10

a[0]

a[1]

a[2]

a[3]

a[4]
Page 12
Single dimensional Array Working
When user inputting data in array
i=2
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

a[0]

a[1]

a[2]

a[3]

a[4]
Page 13
Single dimensional Array Working
When user inputting data in array
i=2
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

a[3]

a[4]
Page 14
Single dimensional Array Working
When user inputting data in array

for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}
i=3

5

10

15

a[0]

a[1]

a[2]

a[3]

a[4]
Page 15
Single dimensional Array Working
When user inputting data in array
i=3
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

a[3]

a[4]
Page 16
Single dimensional Array Working
When user inputting data in array
i=3
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

20

a[3]

a[4]
Page 17
Single dimensional Array Working
When user inputting data in array

for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}
i=4

5

10

15

a[0]

a[1]

a[2]

20

a[3]

a[4]
Page 18
Single dimensional Array Working
When user inputting data in array
i=4
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

20

a[3]

a[4]
Page 19
Single dimensional Array Working
When user inputting data in array
i=4
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

20

25

a[3]

a[4]
Page 20
Single dimensional Array Working
When user inputting data in array

for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}
i=5

5

10

15

a[0]

a[1]

a[2]

20

25

a[3]

a[4]
Page 21
Single dimensional Array Working
When user inputting data in array

i=5
i=5
for(i=0;i<5;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

20

25

a[3]

a[4]
Page 22
Single dimensional Array Working
When user inputting data in array

i=5
i=5
for(i=0; i<5 ;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

20

25

a[3]

a[4]
Page 23
Single dimensional Array Working
When user inputting data in array

i=5
i=5

Here, i=5 & condition is i<5 so
condition not satisfied

for(i=0; i<5 ;i++)
{
scanf(“%d”,&a[i]);
}

5

10

15

a[0]

a[1]

a[2]

20

25

a[3]

a[4]
Page 24
Two Dimensional Array
• A two dimensional array is a collection of elements placed in
rows and columns.
• The syntax used to declare two dimensional array includes two
subscripts, of which one specifies the number of rows and the
other specifies the number of columns.
• These two subscripts are used to reference an element in an
array.

Page 25
Syntax
<data type> <array name> [row size]

[column size];

<data type> <array name> [row size] [column size]={values};

Page 26
Example
int num[3][2]={4,3,5,6,8,9};
or
int num[3][2]={{4,3},{5,6},{8,9}};
values
column size
row size
array name
data type

Page 27
Representation of the 2-D Array
Rows

columns

0th column

1st column

0th row
1st row
2nd row

Page 28
Multi dimensional Arrays
• An array haves 2 or more subscripts, that type of array is called
multi dimensional array.
• The 3 –D array is called as multidimensional array this can be
thought of as an array of two dimensional arrays.
• Each element of a 3-D array is accessed using subscripts, one
for each dimension.

Page 29
Multiple Dimensional Array
• Tables with rows and columns (m by n array)
• Like matrices: specify row, then column
Column 0

Column 1

Column 2

Column 3

Row 0

a[ 0 ][ 0 ]

a[ 0 ][ 1 ]

a[ 0 ][ 2 ]

a[ 0 ][ 3 ]

Row 1

a[ 1 ][ 0 ]

a[ 1 ][ 1 ]

a[ 1 ][ 2 ]

a[ 1 ][ 3 ]

a[ 2 ][ 0 ]

a[ 2 ][ 1 ]

a[ 2 ][ 2 ]

a[ 2 ][ 3 ]

Row 2

Column subscript
Array name
Row subscript

Page 30
Initialization
• int b[2][2] = {{1,2},{3,4}};
• Initializers grouped by row in braces
• If not enough, unspecified elements set to zero
int b[2][2] = {{1},{3,4}};

Page 31
Important
• The most important thing to remember about array
allocation is that the elements of the array are indexed
starting at 0, not 1. If the number of cells in an array is
N, then the indexes run from 0 to N-1.

Page 32
ARRAYS-40

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Sparse matrix
Sparse matrixSparse matrix
Sparse matrix
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Shell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort AlgorithmShell Sort and Selection Sort Algorithm
Shell Sort and Selection Sort Algorithm
 
Selection sort
Selection sortSelection sort
Selection sort
 
Linear search algorithm
Linear search algorithmLinear search algorithm
Linear search algorithm
 
Queues
QueuesQueues
Queues
 
Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)Queue AS an ADT (Abstract Data Type)
Queue AS an ADT (Abstract Data Type)
 
Stack - Data Structure
Stack - Data StructureStack - Data Structure
Stack - Data Structure
 
Sorting types and Algorithms
Sorting types and AlgorithmsSorting types and Algorithms
Sorting types and Algorithms
 
Queue
QueueQueue
Queue
 
stack
stackstack
stack
 
Data structure by Digvijay
Data structure by DigvijayData structure by Digvijay
Data structure by Digvijay
 
Stack - Operations and Applications
Stack - Operations and ApplicationsStack - Operations and Applications
Stack - Operations and Applications
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
 
Infix postfixcoversion
Infix postfixcoversionInfix postfixcoversion
Infix postfixcoversion
 
stack presentation
stack presentationstack presentation
stack presentation
 
C program to implement linked list using array abstract data type
C program to implement linked list using array abstract data typeC program to implement linked list using array abstract data type
C program to implement linked list using array abstract data type
 
Linked list
Linked listLinked list
Linked list
 
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
 
Array
ArrayArray
Array
 

Destacado

Global environmental issues
Global environmental issuesGlobal environmental issues
Global environmental issuesTejas Patel
 
Class 4 - PHP Arrays
Class 4 - PHP ArraysClass 4 - PHP Arrays
Class 4 - PHP ArraysAhmed Swilam
 
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE abile technologies
 
Human Body - Muscular System
Human Body - Muscular SystemHuman Body - Muscular System
Human Body - Muscular Systemvzt00
 
Task 2 working to a brief pro-forma
Task 2   working to a brief pro-formaTask 2   working to a brief pro-forma
Task 2 working to a brief pro-formaharisshaikhPBM
 
ایتالیا و استقرار مجدد حاکمیت قانون در افغانستان
ایتالیا و استقرار مجدد حاکمیت قانون در افغانستانایتالیا و استقرار مجدد حاکمیت قانون در افغانستان
ایتالیا و استقرار مجدد حاکمیت قانون در افغانستانIDCOAFGHANISTAN
 
Evaluation Question 3
Evaluation Question 3Evaluation Question 3
Evaluation Question 3Jacknight
 
تحقیق پیرامون محاکم قانونی افغانستان
تحقیق پیرامون محاکم قانونی افغانستانتحقیق پیرامون محاکم قانونی افغانستان
تحقیق پیرامون محاکم قانونی افغانستانIDCOAFGHANISTAN
 
Egg Program - End 3rd year -
Egg Program - End 3rd year - Egg Program - End 3rd year -
Egg Program - End 3rd year - Ngovan93
 
Slide hm 2015 indo
Slide hm 2015 indoSlide hm 2015 indo
Slide hm 2015 indoShuman_Ko
 
Gogoeta egiteko lekua ibon
Gogoeta egiteko lekua ibonGogoeta egiteko lekua ibon
Gogoeta egiteko lekua ibonibonlaka
 
Praveen datla business_development_manager_15_years_cv
Praveen datla business_development_manager_15_years_cvPraveen datla business_development_manager_15_years_cv
Praveen datla business_development_manager_15_years_cvPraveen Datla
 
Reformasi pemda (riview)
Reformasi pemda (riview)Reformasi pemda (riview)
Reformasi pemda (riview)ricky04
 

Destacado (20)

Global environmental issues
Global environmental issuesGlobal environmental issues
Global environmental issues
 
Class 4 - PHP Arrays
Class 4 - PHP ArraysClass 4 - PHP Arrays
Class 4 - PHP Arrays
 
Task 8
Task 8Task 8
Task 8
 
2 tinggal 2 tamu
2 tinggal 2 tamu2 tinggal 2 tamu
2 tinggal 2 tamu
 
Tqm presentation
Tqm presentationTqm presentation
Tqm presentation
 
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
JAVA J2EE Training in Coimbatore - Fundamentals of Java J2EE
 
Human Body - Muscular System
Human Body - Muscular SystemHuman Body - Muscular System
Human Body - Muscular System
 
Tic
TicTic
Tic
 
Task 2 working to a brief pro-forma
Task 2   working to a brief pro-formaTask 2   working to a brief pro-forma
Task 2 working to a brief pro-forma
 
ایتالیا و استقرار مجدد حاکمیت قانون در افغانستان
ایتالیا و استقرار مجدد حاکمیت قانون در افغانستانایتالیا و استقرار مجدد حاکمیت قانون در افغانستان
ایتالیا و استقرار مجدد حاکمیت قانون در افغانستان
 
Evaluation Question 3
Evaluation Question 3Evaluation Question 3
Evaluation Question 3
 
تحقیق پیرامون محاکم قانونی افغانستان
تحقیق پیرامون محاکم قانونی افغانستانتحقیق پیرامون محاکم قانونی افغانستان
تحقیق پیرامون محاکم قانونی افغانستان
 
Transcript+Cer
Transcript+CerTranscript+Cer
Transcript+Cer
 
CXPA Finland Ajankohtaista - Certified Customer Experience Professional (CCXP...
CXPA Finland Ajankohtaista - Certified Customer Experience Professional (CCXP...CXPA Finland Ajankohtaista - Certified Customer Experience Professional (CCXP...
CXPA Finland Ajankohtaista - Certified Customer Experience Professional (CCXP...
 
Egg Program - End 3rd year -
Egg Program - End 3rd year - Egg Program - End 3rd year -
Egg Program - End 3rd year -
 
Slide hm 2015 indo
Slide hm 2015 indoSlide hm 2015 indo
Slide hm 2015 indo
 
EECS 497 Intro
EECS 497 IntroEECS 497 Intro
EECS 497 Intro
 
Gogoeta egiteko lekua ibon
Gogoeta egiteko lekua ibonGogoeta egiteko lekua ibon
Gogoeta egiteko lekua ibon
 
Praveen datla business_development_manager_15_years_cv
Praveen datla business_development_manager_15_years_cvPraveen datla business_development_manager_15_years_cv
Praveen datla business_development_manager_15_years_cv
 
Reformasi pemda (riview)
Reformasi pemda (riview)Reformasi pemda (riview)
Reformasi pemda (riview)
 

Similar a ARRAYS-40

Similar a ARRAYS-40 (20)

Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
Array
ArrayArray
Array
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
Arrays
ArraysArrays
Arrays
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
 
Arrays in C language
Arrays in C languageArrays in C language
Arrays in C language
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
BHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptxBHARGAVIARRAY.PPT.pptx
BHARGAVIARRAY.PPT.pptx
 
C Programming : Arrays
C Programming : ArraysC Programming : Arrays
C Programming : Arrays
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
Python array
Python arrayPython array
Python array
 
R training3
R training3R training3
R training3
 
Arrays
ArraysArrays
Arrays
 
Introduction to Data Structure
Introduction to Data Structure Introduction to Data Structure
Introduction to Data Structure
 
Unit4 Slides
Unit4 SlidesUnit4 Slides
Unit4 Slides
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 

Último

Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsManeerUddin
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...JojoEDelaCruz
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
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
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
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
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
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
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Último (20)

Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Food processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture honsFood processing presentation for bsc agriculture hons
Food processing presentation for bsc agriculture hons
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
ENG 5 Q4 WEEk 1 DAY 1 Restate sentences heard in one’s own words. Use appropr...
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
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
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
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
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
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
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

ARRAYS-40

  • 2. Content… • • • • What are arrays? Types of arrays Single dimensional array Multi dimensional array Page 2
  • 3. What are Arrays? • Array is a data structure, which provides the facility to store a collection of data of same type under single variable name. • It is a group of consecutive memory locations having same name and type. Page 3
  • 4. Types • One dimensional • Multi dimensional Page 4
  • 5. Single Dimensional Array • Element specified by single subscript • Array declaration is made by specifying the data type, it’s name and the number of space (size) so that the computer may reserve the appropriate amount of memory. Syntax type array_name [ size ] Base type of array Name of No. of elements that can be array stored: Can be a integer value without the sign Page 5
  • 6. Single dimensional Array Working When user inputting data in array i=0 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } a[0] a[1] a[2] a[3] a[4] Page 6
  • 7. Single dimensional Array Working When user inputting data in array i=0 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } a[0] a[1] a[2] a[3] a[4] Page 7
  • 8. Single dimensional Array Working When user inputting data in array i=0 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 a[0] a[1] a[2] a[3] a[4] Page 8
  • 9. Single dimensional Array Working When user inputting data in array for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } i=1 5 a[0] a[1] a[2] a[3] a[4] Page 9
  • 10. Single dimensional Array Working When user inputting data in array i=1 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 a[0] a[1] a[2] a[3] a[4] Page 10
  • 11. Single dimensional Array Working When user inputting data in array i=1 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 a[0] a[1] a[2] a[3] a[4] Page 11
  • 12. Single dimensional Array Working When user inputting data in array for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } i=2 5 10 a[0] a[1] a[2] a[3] a[4] Page 12
  • 13. Single dimensional Array Working When user inputting data in array i=2 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 a[0] a[1] a[2] a[3] a[4] Page 13
  • 14. Single dimensional Array Working When user inputting data in array i=2 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] a[3] a[4] Page 14
  • 15. Single dimensional Array Working When user inputting data in array for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } i=3 5 10 15 a[0] a[1] a[2] a[3] a[4] Page 15
  • 16. Single dimensional Array Working When user inputting data in array i=3 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] a[3] a[4] Page 16
  • 17. Single dimensional Array Working When user inputting data in array i=3 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] 20 a[3] a[4] Page 17
  • 18. Single dimensional Array Working When user inputting data in array for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } i=4 5 10 15 a[0] a[1] a[2] 20 a[3] a[4] Page 18
  • 19. Single dimensional Array Working When user inputting data in array i=4 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] 20 a[3] a[4] Page 19
  • 20. Single dimensional Array Working When user inputting data in array i=4 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] 20 25 a[3] a[4] Page 20
  • 21. Single dimensional Array Working When user inputting data in array for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } i=5 5 10 15 a[0] a[1] a[2] 20 25 a[3] a[4] Page 21
  • 22. Single dimensional Array Working When user inputting data in array i=5 i=5 for(i=0;i<5;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] 20 25 a[3] a[4] Page 22
  • 23. Single dimensional Array Working When user inputting data in array i=5 i=5 for(i=0; i<5 ;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] 20 25 a[3] a[4] Page 23
  • 24. Single dimensional Array Working When user inputting data in array i=5 i=5 Here, i=5 & condition is i<5 so condition not satisfied for(i=0; i<5 ;i++) { scanf(“%d”,&a[i]); } 5 10 15 a[0] a[1] a[2] 20 25 a[3] a[4] Page 24
  • 25. Two Dimensional Array • A two dimensional array is a collection of elements placed in rows and columns. • The syntax used to declare two dimensional array includes two subscripts, of which one specifies the number of rows and the other specifies the number of columns. • These two subscripts are used to reference an element in an array. Page 25
  • 26. Syntax <data type> <array name> [row size] [column size]; <data type> <array name> [row size] [column size]={values}; Page 26
  • 28. Representation of the 2-D Array Rows columns 0th column 1st column 0th row 1st row 2nd row Page 28
  • 29. Multi dimensional Arrays • An array haves 2 or more subscripts, that type of array is called multi dimensional array. • The 3 –D array is called as multidimensional array this can be thought of as an array of two dimensional arrays. • Each element of a 3-D array is accessed using subscripts, one for each dimension. Page 29
  • 30. Multiple Dimensional Array • Tables with rows and columns (m by n array) • Like matrices: specify row, then column Column 0 Column 1 Column 2 Column 3 Row 0 a[ 0 ][ 0 ] a[ 0 ][ 1 ] a[ 0 ][ 2 ] a[ 0 ][ 3 ] Row 1 a[ 1 ][ 0 ] a[ 1 ][ 1 ] a[ 1 ][ 2 ] a[ 1 ][ 3 ] a[ 2 ][ 0 ] a[ 2 ][ 1 ] a[ 2 ][ 2 ] a[ 2 ][ 3 ] Row 2 Column subscript Array name Row subscript Page 30
  • 31. Initialization • int b[2][2] = {{1,2},{3,4}}; • Initializers grouped by row in braces • If not enough, unspecified elements set to zero int b[2][2] = {{1},{3,4}}; Page 31
  • 32. Important • The most important thing to remember about array allocation is that the elements of the array are indexed starting at 0, not 1. If the number of cells in an array is N, then the indexes run from 0 to N-1. Page 32