際際滷

際際滷Share a Scribd company logo
Arrays Designed By:Chandan deep singh  College  Guru nanak engg college,  ludhiana, Punjab
Definition Array is a collection of variables of same data type with a common name
USE Can store multiple values of same type Values are stored in adjacent memory locations [ ] is the operator used
Example Int students[5] Allocate following memory Fifth element Fourth element Third element Second element First element
Types of Arrays One Dimensional Arrays Two Dimensional Arrays Multi Dimensional Arrays 3D Array, 4D Arrays etc. A[0] A[1] A[2] A[3] A[4] A[5] A[0][0] A[0][1] A[0][2] A[0][3] A[0][4] A[1][0] A[1][1] A[1][2] A[1][3] A[1][4 A[2][1] A[2][2] A[2][3] A[2][3] A[2][4]
Declaration of Array One Dimensional Arrays int A[10]; float B[20]; char C[20]; Two Dimensional Arrays int X[5][5]; char Y[5][25];
Initialization of the Array int A[5]= {1,2,3,4,5}; int ARR[ ] = {1,2,3,4,5,6}; char B[20]=Rudrapur; float C[5]={2.4,3.5,1.5}; int D[2][3]={{1,2},   {3,4},   {5,6}};
Accessing Array Elements In C++ first element of the array is always at zero position. A[0] A[1] A[2] A[3] A[4] A[5]
Sample Program on 1-D Array #include<iostream.h> void main() { int A[10],i; for(i=0;i<10;i++) { cout<<Enter a number: ; cin>A[i]; } cout<<\n Array Contents\n; for(i=0;i<10;i++) { cout<<A[i]<< ; } }
Sample Program on 2-D Array #include<iostream.h> void main() { int A[3][4],i,j; for(i=0;i<20;i++)   for(j=0j<4;j++)   { cout<<Enter a number: ; cin>A[i];   } cout<<\n Array Contents\n; for(i=0;i<10;i++) {  for(j=0j<4;j++)   cout<<A[i]<<  ;   cout<<endl; } }
Address Calculation in 2D Arrays  Row Major Column Major 0 1 2 3 4 0  1  2  3  4  5  Base Address : 1000 Address of Location X Address of Location Y Size of Each Element : 2 Bytes In Row Major  : 1032 In Column Major : 1016  In Row Major  : 1018 In Column Major : 1032  Y X
Address Calculation in Row Major A[i][j]= B + [i*n + j] Where B=Base address of the array n = Total column of the array i = Row number of desired row j = Column number of desired row
Address in Column Major A[i][j]= B + [i + j*m] Where B=Base address of the array m = Total rows of the array i = Row number of desired row j = Column number of desired row
THANKS FOR YOUR TIME
Ad

Recommended

Multidimensional array in C
Multidimensional array in C
Smit Parikh
Multi dimensional arrays
Multi dimensional arrays
Aseelhalees
A Presentation About Array Manipulation(Insertion & Deletion in an array)
A Presentation About Array Manipulation(Insertion & Deletion in an array)
Imdadul Himu
Chapter 7.3
Chapter 7.3
sotlsoc
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
Array,MULTI ARRAY, IN C
Array,MULTI ARRAY, IN C
naveed jamali
C Programming : Arrays
C Programming : Arrays
Gagan Deep
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT
LATHA LAKSHMI
DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1
Malikireddy Bramhananda Reddy
Array ppt
Array ppt
Kaushal Mehta
ARRAY
ARRAY
ayush raj
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
Maulen Bale
Introduction to Array ppt
Introduction to Array ppt
sandhya yadav
Arrays
Arrays
Chirag vasava
Array in c
Array in c
AnIsh Kumar
Arrays and structures
Arrays and structures
Mohd Arif
Two dimensional arrays
Two dimensional arrays
Neeru Mittal
Array in-c
Array in-c
Samsil Arefin
Lecture17 arrays.ppt
Lecture17 arrays.ppt
eShikshak
Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]
Muhammad Hammad Waseem
Array C programming
Array C programming
Prionto Abdullah
Lecture 8
Lecture 8
Soran University
Array in C
Array in C
adityas29
Arrays
Arrays
Shakila Mahjabin
Arrays in C
Arrays in C
Kamruddin Nur
Arrays In C
Arrays In C
yndaravind
SPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
Array in c++
Array in c++
Mahesha Mano
arrays.pptx
arrays.pptx
NehaJain919374
ARRAYSCPP.pptx
ARRAYSCPP.pptx
727822TUCS116MOHANKU

More Related Content

What's hot (20)

DATASTRUCTURES UNIT-1
DATASTRUCTURES UNIT-1
Malikireddy Bramhananda Reddy
Array ppt
Array ppt
Kaushal Mehta
ARRAY
ARRAY
ayush raj
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
Maulen Bale
Introduction to Array ppt
Introduction to Array ppt
sandhya yadav
Arrays
Arrays
Chirag vasava
Array in c
Array in c
AnIsh Kumar
Arrays and structures
Arrays and structures
Mohd Arif
Two dimensional arrays
Two dimensional arrays
Neeru Mittal
Array in-c
Array in-c
Samsil Arefin
Lecture17 arrays.ppt
Lecture17 arrays.ppt
eShikshak
Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]
Muhammad Hammad Waseem
Array C programming
Array C programming
Prionto Abdullah
Lecture 8
Lecture 8
Soran University
Array in C
Array in C
adityas29
Arrays
Arrays
Shakila Mahjabin
Arrays in C
Arrays in C
Kamruddin Nur
Arrays In C
Arrays In C
yndaravind
SPL 10 | One Dimensional Array in C
SPL 10 | One Dimensional Array in C
Mohammad Imam Hossain
Array in c++
Array in c++
Mahesha Mano

Similar to Chandan (20)

arrays.pptx
arrays.pptx
NehaJain919374
ARRAYSCPP.pptx
ARRAYSCPP.pptx
727822TUCS116MOHANKU
Arrays and library functions
Arrays and library functions
Swarup Boro
ARRAYS.pptx
ARRAYS.pptx
MamataAnilgod
Arrays and library functions
Arrays and library functions
Swarup Kumar Boro
unit-2-dsa.pptx
unit-2-dsa.pptx
sayalishivarkar1
2- Dimensional Arrays
2- Dimensional Arrays
Education Front
UNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptx
sangeeta borde
Data structure array
Data structure array
MajidHamidAli
Two Dimensional Array
Two Dimensional Array
dincyjain
Module_3_Arrays - Updated.pptx............
Module_3_Arrays - Updated.pptx............
ChiragKankani
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
brajmohan21nitj
arrays.pptx
arrays.pptx
HarmanShergill5
Fp201 unit4
Fp201 unit4
rohassanie
DSA Unit II array.pptx
DSA Unit II array.pptx
sayalishivarkar1
Lec2&3_DataStructure
Lec2&3_DataStructure
Ibrahim El-Torbany
Lec2
Lec2
Saad Gabr
Lec2&3 data structure
Lec2&3 data structure
Saad Gabr
Arrays.pptx
Arrays.pptx
Koteswari Kasireddy
Structured Data Type Arrays
Structured Data Type Arrays
Praveen M Jigajinni
Arrays and library functions
Arrays and library functions
Swarup Boro
Arrays and library functions
Arrays and library functions
Swarup Kumar Boro
2- Dimensional Arrays
2- Dimensional Arrays
Education Front
UNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptx
sangeeta borde
Data structure array
Data structure array
MajidHamidAli
Two Dimensional Array
Two Dimensional Array
dincyjain
Module_3_Arrays - Updated.pptx............
Module_3_Arrays - Updated.pptx............
ChiragKankani
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
ADVANCED DATA STRUCTURES AND ALGORITHMS.pptx
brajmohan21nitj
Fp201 unit4
Fp201 unit4
rohassanie
Lec2&3 data structure
Lec2&3 data structure
Saad Gabr
Ad

Recently uploaded (20)

Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
Turning the Page How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Turning the Page How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Impelsys Inc.
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Powering Multi-Page Web Applications Using Flow Apps and FME Data Streaming
Safe Software
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Seminar: Authentication for a Billion Consumers - Amazon.pptx
FIDO Alliance
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
From Manual to Auto Searching- FME in the Driver's Seat
From Manual to Auto Searching- FME in the Driver's Seat
Safe Software
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Smarter Aviation Data Management: Lessons from Swedavia Airports and Sweco
Safe Software
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
AI VIDEO MAGAZINE - June 2025 - r/aivideo
AI VIDEO MAGAZINE - June 2025 - r/aivideo
1pcity Studios, Inc
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
Turning the Page How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Turning the Page How AI is Exponentially Increasing Speed, Accuracy, and Ef...
Impelsys Inc.
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
Ad

Chandan

  • 1. Arrays Designed By:Chandan deep singh College Guru nanak engg college, ludhiana, Punjab
  • 2. Definition Array is a collection of variables of same data type with a common name
  • 3. USE Can store multiple values of same type Values are stored in adjacent memory locations [ ] is the operator used
  • 4. Example Int students[5] Allocate following memory Fifth element Fourth element Third element Second element First element
  • 5. Types of Arrays One Dimensional Arrays Two Dimensional Arrays Multi Dimensional Arrays 3D Array, 4D Arrays etc. A[0] A[1] A[2] A[3] A[4] A[5] A[0][0] A[0][1] A[0][2] A[0][3] A[0][4] A[1][0] A[1][1] A[1][2] A[1][3] A[1][4 A[2][1] A[2][2] A[2][3] A[2][3] A[2][4]
  • 6. Declaration of Array One Dimensional Arrays int A[10]; float B[20]; char C[20]; Two Dimensional Arrays int X[5][5]; char Y[5][25];
  • 7. Initialization of the Array int A[5]= {1,2,3,4,5}; int ARR[ ] = {1,2,3,4,5,6}; char B[20]=Rudrapur; float C[5]={2.4,3.5,1.5}; int D[2][3]={{1,2}, {3,4}, {5,6}};
  • 8. Accessing Array Elements In C++ first element of the array is always at zero position. A[0] A[1] A[2] A[3] A[4] A[5]
  • 9. Sample Program on 1-D Array #include<iostream.h> void main() { int A[10],i; for(i=0;i<10;i++) { cout<<Enter a number: ; cin>A[i]; } cout<<\n Array Contents\n; for(i=0;i<10;i++) { cout<<A[i]<< ; } }
  • 10. Sample Program on 2-D Array #include<iostream.h> void main() { int A[3][4],i,j; for(i=0;i<20;i++) for(j=0j<4;j++) { cout<<Enter a number: ; cin>A[i]; } cout<<\n Array Contents\n; for(i=0;i<10;i++) { for(j=0j<4;j++) cout<<A[i]<< ; cout<<endl; } }
  • 11. Address Calculation in 2D Arrays Row Major Column Major 0 1 2 3 4 0 1 2 3 4 5 Base Address : 1000 Address of Location X Address of Location Y Size of Each Element : 2 Bytes In Row Major : 1032 In Column Major : 1016 In Row Major : 1018 In Column Major : 1032 Y X
  • 12. Address Calculation in Row Major A[i][j]= B + [i*n + j] Where B=Base address of the array n = Total column of the array i = Row number of desired row j = Column number of desired row
  • 13. Address in Column Major A[i][j]= B + [i + j*m] Where B=Base address of the array m = Total rows of the array i = Row number of desired row j = Column number of desired row