SlideShare una empresa de Scribd logo
1 de 19
Lecture 12Lecture 12
Version 1.0Version 1.0
Multidimensional ArraysMultidimensional Arrays
Passing Arrays to FuncionPassing Arrays to Funcion
2Rushdi Shams, Dept of CSE, KUET, Bangladesh
Multidimensional ArrayMultidimensional Array
 Arrays in C can have multiple subscriptsArrays in C can have multiple subscripts
 A common use of multiple subscripted arrays isA common use of multiple subscripted arrays is
to represent tables of valuesto represent tables of values
 To identify a particular table element, we mustTo identify a particular table element, we must
specify two subscripts: the first identifies thespecify two subscripts: the first identifies the
row and the second identifies the columnrow and the second identifies the column
3Rushdi Shams, Dept of CSE, KUET, Bangladesh
Two Dimensional ArrayTwo Dimensional Array
 Arrays that require two subscripts to identify aArrays that require two subscripts to identify a
particular element are called double subscriptedparticular element are called double subscripted
arraysarrays
 ANSI standard supports at least 12 subscriptsANSI standard supports at least 12 subscripts
4Rushdi Shams, Dept of CSE, KUET, Bangladesh
Two Dimensional ArrayTwo Dimensional Array
 When we say a 3X4 array, we declare it as follows-When we say a 3X4 array, we declare it as follows-
int a [3][4];int a [3][4];
So, the first subscript denotes the row and the second subscriptSo, the first subscript denotes the row and the second subscript
denotes the columndenotes the column
5Rushdi Shams, Dept of CSE, KUET, Bangladesh
Two Dimensional ArrayTwo Dimensional Array
 A multiple subscripted array can be initialized inA multiple subscripted array can be initialized in
its declaration much like a single subscriptedits declaration much like a single subscripted
arrayarray
int b [2] [2] = {{1,2}, {3,4}};int b [2] [2] = {{1,2}, {3,4}};
 in that case, 1 and 2 initialize b[0][0] and b[0][1]in that case, 1 and 2 initialize b[0][0] and b[0][1]
and 3 and 4 initialize b[1][0] and b[1][1]and 3 and 4 initialize b[1][0] and b[1][1]
6Rushdi Shams, Dept of CSE, KUET, Bangladesh
Two Dimensional ArrayTwo Dimensional Array
7Rushdi Shams, Dept of CSE, KUET, Bangladesh
The OutputThe Output
8Rushdi Shams, Dept of CSE, KUET, Bangladesh
Two Dimensional ArraysTwo Dimensional Arrays
9Rushdi Shams, Dept of CSE, KUET, Bangladesh
The OutputThe Output
10Rushdi Shams, Dept of CSE, KUET, Bangladesh
Remember!!Remember!!
 that while initializing a 2-D array it is necessarythat while initializing a 2-D array it is necessary
to mention the second (column) dimension,to mention the second (column) dimension,
whereas the first dimension (row) is optionalwhereas the first dimension (row) is optional
11Rushdi Shams, Dept of CSE, KUET, Bangladesh
Valid DeclarationValid Declaration
12Rushdi Shams, Dept of CSE, KUET, Bangladesh
Invalid DeclarationInvalid Declaration
13Rushdi Shams, Dept of CSE, KUET, Bangladesh
Three Dimensional ArraysThree Dimensional Arrays
14Rushdi Shams, Dept of CSE, KUET, Bangladesh
Passing Arrays to FunctionsPassing Arrays to Functions
 Array elements can be passed to a function byArray elements can be passed to a function by
calling the function by value, or by referencecalling the function by value, or by reference
 In the call by value we pass values of arrayIn the call by value we pass values of array
elements to the functionelements to the function
 in the call by reference we pass addresses ofin the call by reference we pass addresses of
array elements to the functionarray elements to the function
 As we did not see call by reference yet, we willAs we did not see call by reference yet, we will
see that latersee that later
15Rushdi Shams, Dept of CSE, KUET, Bangladesh
Passing Arrays to FunctionsPassing Arrays to Functions
16Rushdi Shams, Dept of CSE, KUET, Bangladesh
OutputOutput
17Rushdi Shams, Dept of CSE, KUET, Bangladesh
Passing Arrays to FunctionsPassing Arrays to Functions
18Rushdi Shams, Dept of CSE, KUET, Bangladesh
Function Prototype for functionsFunction Prototype for functions
taking arrays as argumentstaking arrays as arguments
 The function prototype for this will be-The function prototype for this will be-
void print (int [ ][ ], int , int );void print (int [ ][ ], int , int );
19Rushdi Shams, Dept of CSE, KUET, Bangladesh
OutputOutput

Más contenido relacionado

La actualidad más candente

02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array PointerTareq Hasan
 
7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScriptpcnmtutorials
 
8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScriptpcnmtutorials
 
Data structure week 2
Data structure week 2Data structure week 2
Data structure week 2karmuhtam
 
NaBL: A Meta-Language for Declarative Name Binding and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding  and Scope RulesNaBL: A Meta-Language for Declarative Name Binding  and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding and Scope RulesEelco Visser
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programmingnmahi96
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Philip Schwarz
 
1. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES61. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6pcnmtutorials
 
Strings in c
Strings in cStrings in c
Strings in cvampugani
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Philip Schwarz
 
Assembly language
Assembly languageAssembly language
Assembly languagePiyush Jain
 
Assembly Language String Chapter
Assembly Language String Chapter Assembly Language String Chapter
Assembly Language String Chapter Atieq-ur -Rehman
 

La actualidad más candente (20)

02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript7. Rest parameters | ES6 | JavaScript
7. Rest parameters | ES6 | JavaScript
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript8. Spread Syntax | ES6 | JavaScript
8. Spread Syntax | ES6 | JavaScript
 
Matlab strings
Matlab stringsMatlab strings
Matlab strings
 
Data structure week 2
Data structure week 2Data structure week 2
Data structure week 2
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
NaBL: A Meta-Language for Declarative Name Binding and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding  and Scope RulesNaBL: A Meta-Language for Declarative Name Binding  and Scope Rules
NaBL: A Meta-Language for Declarative Name Binding and Scope Rules
 
Arrays-Computer programming
Arrays-Computer programmingArrays-Computer programming
Arrays-Computer programming
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part 4
 
1. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES61. Arrow Functions | JavaScript | ES6
1. Arrow Functions | JavaScript | ES6
 
Strings in c
Strings in cStrings in c
Strings in c
 
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
Folding Unfolded - Polyglot FP for Fun and Profit - Haskell and Scala - Part ...
 
String.ppt
String.pptString.ppt
String.ppt
 
Clojure basics
Clojure basicsClojure basics
Clojure basics
 
Assembly language
Assembly languageAssembly language
Assembly language
 
Arrays and strings in c++
Arrays and strings in c++Arrays and strings in c++
Arrays and strings in c++
 
Cs419 lec7 cfg
Cs419 lec7   cfgCs419 lec7   cfg
Cs419 lec7 cfg
 
Assembly Language String Chapter
Assembly Language String Chapter Assembly Language String Chapter
Assembly Language String Chapter
 
Modern C++
Modern C++Modern C++
Modern C++
 

Destacado

L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programmingRushdi Shams
 
Lec 15. Pointers and Arrays
Lec 15. Pointers and ArraysLec 15. Pointers and Arrays
Lec 15. Pointers and ArraysRushdi Shams
 
Lec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by ValuesLec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by ValuesRushdi Shams
 
Lec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptLec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptRushdi Shams
 
Lec 23. Files (Part II)
Lec 23. Files (Part II)Lec 23. Files (Part II)
Lec 23. Files (Part II)Rushdi Shams
 
L14 l15 Object Oriented DBMS
L14 l15  Object Oriented DBMSL14 l15  Object Oriented DBMS
L14 l15 Object Oriented DBMSRushdi Shams
 
L4 domain integrity
L4  domain integrityL4  domain integrity
L4 domain integrityRushdi Shams
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logicRushdi Shams
 

Destacado (9)

L9 l10 server side programming
L9 l10  server side programmingL9 l10  server side programming
L9 l10 server side programming
 
Lec 15. Pointers and Arrays
Lec 15. Pointers and ArraysLec 15. Pointers and Arrays
Lec 15. Pointers and Arrays
 
Lec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by ValuesLec 09. Introduction to Functions / Call by Values
Lec 09. Introduction to Functions / Call by Values
 
Lec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory ConceptLec 02. C Program Structure / C Memory Concept
Lec 02. C Program Structure / C Memory Concept
 
Lec 23. Files (Part II)
Lec 23. Files (Part II)Lec 23. Files (Part II)
Lec 23. Files (Part II)
 
L14 l15 Object Oriented DBMS
L14 l15  Object Oriented DBMSL14 l15  Object Oriented DBMS
L14 l15 Object Oriented DBMS
 
L4 domain integrity
L4  domain integrityL4  domain integrity
L4 domain integrity
 
Probabilistic logic
Probabilistic logicProbabilistic logic
Probabilistic logic
 
L3 defense
L3  defenseL3  defense
L3 defense
 

Similar a Lec 12. Multidimensional Arrays / Passing Arrays to Functions

Lec 11. One Dimensional Arrays
Lec 11. One Dimensional ArraysLec 11. One Dimensional Arrays
Lec 11. One Dimensional ArraysRushdi Shams
 
Lec 10. Functions (Part II)
Lec 10. Functions (Part II)Lec 10. Functions (Part II)
Lec 10. Functions (Part II)Rushdi Shams
 
Java R20 - UNIT-3.docx
Java R20 - UNIT-3.docxJava R20 - UNIT-3.docx
Java R20 - UNIT-3.docxPamarthi Kumar
 
Array String - Web Programming
Array String - Web ProgrammingArray String - Web Programming
Array String - Web ProgrammingAmirul Azhar
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysEng Teong Cheah
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R langsenthil0809
 
Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuplesAbed Bukhari
 
Lec 14. Call by Reference
Lec 14. Call by ReferenceLec 14. Call by Reference
Lec 14. Call by ReferenceRushdi Shams
 
arrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdfarrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdfMarlonMagtibay2
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in Carshpreetkaur07
 
Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6dplunkett
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog Pushpa Yakkala
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Guy Lebanon
 

Similar a Lec 12. Multidimensional Arrays / Passing Arrays to Functions (20)

Lec 11. One Dimensional Arrays
Lec 11. One Dimensional ArraysLec 11. One Dimensional Arrays
Lec 11. One Dimensional Arrays
 
Lec 10. Functions (Part II)
Lec 10. Functions (Part II)Lec 10. Functions (Part II)
Lec 10. Functions (Part II)
 
Java R20 - UNIT-3.docx
Java R20 - UNIT-3.docxJava R20 - UNIT-3.docx
Java R20 - UNIT-3.docx
 
Array String - Web Programming
Array String - Web ProgrammingArray String - Web Programming
Array String - Web Programming
 
Unit 2
Unit 2Unit 2
Unit 2
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
 
Get started with R lang
Get started with R langGet started with R lang
Get started with R lang
 
Csharp4 arrays and_tuples
Csharp4 arrays and_tuplesCsharp4 arrays and_tuples
Csharp4 arrays and_tuples
 
CAP615-Unit1.pptx
CAP615-Unit1.pptxCAP615-Unit1.pptx
CAP615-Unit1.pptx
 
Lec 14. Call by Reference
Lec 14. Call by ReferenceLec 14. Call by Reference
Lec 14. Call by Reference
 
arrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdfarrays-130116232821-phpapp02.pdf
arrays-130116232821-phpapp02.pdf
 
Plc (1)
Plc (1)Plc (1)
Plc (1)
 
Array.pptx
Array.pptxArray.pptx
Array.pptx
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
arrays.pptx
arrays.pptxarrays.pptx
arrays.pptx
 
2ds
2ds2ds
2ds
 
Ap Power Point Chpt6
Ap Power Point Chpt6Ap Power Point Chpt6
Ap Power Point Chpt6
 
Lec 16. Strings
Lec 16. StringsLec 16. Strings
Lec 16. Strings
 
Introduction to System verilog
Introduction to System verilog Introduction to System verilog
Introduction to System verilog
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)
 

Más de Rushdi Shams

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchRushdi Shams
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IRRushdi Shams
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101Rushdi Shams
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processingRushdi Shams
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: ParsingRushdi Shams
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translationRushdi Shams
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translationRushdi Shams
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semanticsRushdi Shams
 
Propositional logic
Propositional logicPropositional logic
Propositional logicRushdi Shams
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structureRushdi Shams
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representationRushdi Shams
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hackingRushdi Shams
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)Rushdi Shams
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process modelsRushdi Shams
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineeringRushdi Shams
 

Más de Rushdi Shams (20)

Research Methodology and Tips on Better Research
Research Methodology and Tips on Better ResearchResearch Methodology and Tips on Better Research
Research Methodology and Tips on Better Research
 
Common evaluation measures in NLP and IR
Common evaluation measures in NLP and IRCommon evaluation measures in NLP and IR
Common evaluation measures in NLP and IR
 
Machine learning with nlp 101
Machine learning with nlp 101Machine learning with nlp 101
Machine learning with nlp 101
 
Semi-supervised classification for natural language processing
Semi-supervised classification for natural language processingSemi-supervised classification for natural language processing
Semi-supervised classification for natural language processing
 
Natural Language Processing: Parsing
Natural Language Processing: ParsingNatural Language Processing: Parsing
Natural Language Processing: Parsing
 
Types of machine translation
Types of machine translationTypes of machine translation
Types of machine translation
 
L1 l2 l3 introduction to machine translation
L1 l2 l3  introduction to machine translationL1 l2 l3  introduction to machine translation
L1 l2 l3 introduction to machine translation
 
Syntax and semantics
Syntax and semanticsSyntax and semantics
Syntax and semantics
 
Propositional logic
Propositional logicPropositional logic
Propositional logic
 
L15 fuzzy logic
L15  fuzzy logicL15  fuzzy logic
L15 fuzzy logic
 
Knowledge structure
Knowledge structureKnowledge structure
Knowledge structure
 
Knowledge representation
Knowledge representationKnowledge representation
Knowledge representation
 
First order logic
First order logicFirst order logic
First order logic
 
Belief function
Belief functionBelief function
Belief function
 
L5 understanding hacking
L5  understanding hackingL5  understanding hacking
L5 understanding hacking
 
L4 vpn
L4  vpnL4  vpn
L4 vpn
 
L2 Intrusion Detection System (IDS)
L2  Intrusion Detection System (IDS)L2  Intrusion Detection System (IDS)
L2 Intrusion Detection System (IDS)
 
L1 phishing
L1  phishingL1  phishing
L1 phishing
 
L2 l3 l4 software process models
L2 l3 l4  software process modelsL2 l3 l4  software process models
L2 l3 l4 software process models
 
L1 overview of software engineering
L1  overview of software engineeringL1  overview of software engineering
L1 overview of software engineering
 

Último

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 

Último (20)

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 

Lec 12. Multidimensional Arrays / Passing Arrays to Functions

  • 1. Lecture 12Lecture 12 Version 1.0Version 1.0 Multidimensional ArraysMultidimensional Arrays Passing Arrays to FuncionPassing Arrays to Funcion
  • 2. 2Rushdi Shams, Dept of CSE, KUET, Bangladesh Multidimensional ArrayMultidimensional Array  Arrays in C can have multiple subscriptsArrays in C can have multiple subscripts  A common use of multiple subscripted arrays isA common use of multiple subscripted arrays is to represent tables of valuesto represent tables of values  To identify a particular table element, we mustTo identify a particular table element, we must specify two subscripts: the first identifies thespecify two subscripts: the first identifies the row and the second identifies the columnrow and the second identifies the column
  • 3. 3Rushdi Shams, Dept of CSE, KUET, Bangladesh Two Dimensional ArrayTwo Dimensional Array  Arrays that require two subscripts to identify aArrays that require two subscripts to identify a particular element are called double subscriptedparticular element are called double subscripted arraysarrays  ANSI standard supports at least 12 subscriptsANSI standard supports at least 12 subscripts
  • 4. 4Rushdi Shams, Dept of CSE, KUET, Bangladesh Two Dimensional ArrayTwo Dimensional Array  When we say a 3X4 array, we declare it as follows-When we say a 3X4 array, we declare it as follows- int a [3][4];int a [3][4]; So, the first subscript denotes the row and the second subscriptSo, the first subscript denotes the row and the second subscript denotes the columndenotes the column
  • 5. 5Rushdi Shams, Dept of CSE, KUET, Bangladesh Two Dimensional ArrayTwo Dimensional Array  A multiple subscripted array can be initialized inA multiple subscripted array can be initialized in its declaration much like a single subscriptedits declaration much like a single subscripted arrayarray int b [2] [2] = {{1,2}, {3,4}};int b [2] [2] = {{1,2}, {3,4}};  in that case, 1 and 2 initialize b[0][0] and b[0][1]in that case, 1 and 2 initialize b[0][0] and b[0][1] and 3 and 4 initialize b[1][0] and b[1][1]and 3 and 4 initialize b[1][0] and b[1][1]
  • 6. 6Rushdi Shams, Dept of CSE, KUET, Bangladesh Two Dimensional ArrayTwo Dimensional Array
  • 7. 7Rushdi Shams, Dept of CSE, KUET, Bangladesh The OutputThe Output
  • 8. 8Rushdi Shams, Dept of CSE, KUET, Bangladesh Two Dimensional ArraysTwo Dimensional Arrays
  • 9. 9Rushdi Shams, Dept of CSE, KUET, Bangladesh The OutputThe Output
  • 10. 10Rushdi Shams, Dept of CSE, KUET, Bangladesh Remember!!Remember!!  that while initializing a 2-D array it is necessarythat while initializing a 2-D array it is necessary to mention the second (column) dimension,to mention the second (column) dimension, whereas the first dimension (row) is optionalwhereas the first dimension (row) is optional
  • 11. 11Rushdi Shams, Dept of CSE, KUET, Bangladesh Valid DeclarationValid Declaration
  • 12. 12Rushdi Shams, Dept of CSE, KUET, Bangladesh Invalid DeclarationInvalid Declaration
  • 13. 13Rushdi Shams, Dept of CSE, KUET, Bangladesh Three Dimensional ArraysThree Dimensional Arrays
  • 14. 14Rushdi Shams, Dept of CSE, KUET, Bangladesh Passing Arrays to FunctionsPassing Arrays to Functions  Array elements can be passed to a function byArray elements can be passed to a function by calling the function by value, or by referencecalling the function by value, or by reference  In the call by value we pass values of arrayIn the call by value we pass values of array elements to the functionelements to the function  in the call by reference we pass addresses ofin the call by reference we pass addresses of array elements to the functionarray elements to the function  As we did not see call by reference yet, we willAs we did not see call by reference yet, we will see that latersee that later
  • 15. 15Rushdi Shams, Dept of CSE, KUET, Bangladesh Passing Arrays to FunctionsPassing Arrays to Functions
  • 16. 16Rushdi Shams, Dept of CSE, KUET, Bangladesh OutputOutput
  • 17. 17Rushdi Shams, Dept of CSE, KUET, Bangladesh Passing Arrays to FunctionsPassing Arrays to Functions
  • 18. 18Rushdi Shams, Dept of CSE, KUET, Bangladesh Function Prototype for functionsFunction Prototype for functions taking arrays as argumentstaking arrays as arguments  The function prototype for this will be-The function prototype for this will be- void print (int [ ][ ], int , int );void print (int [ ][ ], int , int );
  • 19. 19Rushdi Shams, Dept of CSE, KUET, Bangladesh OutputOutput