SlideShare uma empresa Scribd logo
1 de 14
Arrays part -2
Author – Subhasis Nayak
Do & Don’t
Multidimensional arrays
• Arrays      can,      however,        get
  multidimensional too.
• We can create an array of any number of
  dimensions, and that is what makes
  multidimensional arrays an interesting
  topic from mathematical points of view.
Declaring multidimensional array
• Each dimension in an array is represented as a
  subscript in the array. Hence for
  – Two-dimensional array has two subscripts
  – three-dimensional array has three subscripts
  – & so on

         int twoDi_array[2][2];
Continue …..
• Keep in mind
  – first subscript = rows
  – Second subscript = columns


         int twoDi_array[2][2];
Positions

    0           1
0   00          01
1   10          11
Example chess board
 • Board[8][8];
00   01 02   03   04 05   06 07
10
20
30
40
50
60
70
Initializing Multidimensional Arrays
• Initialization can      be        done   as   for   uni
  dimensional array
  – Int Array[5][3] = {
    1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 };
                     1    2    3
                     4    5    6
                     7    8    9
                     10   11   12
                     13   14   15
Continue …..
• For sake of clarity and readability we can write
  like this way also
                                   1    2    3
  – int Array[5][3] = { {1,2,3},
                                   4    5    6
                   {4,5,6},
                                   7    8    9
                   {7,8,9},        10   11   12
                   {10,11,12},     13   14   15
                   {13,14,15} };
• The compiler ignores the inner braces, but they
  do make it easier to understand how the
  numbers are distributed.
• When initializing elements of an array, each value
  must be separated by a comma, with-out regard
  to the braces.
• The entire initialization set must be within braces
  & it must end with a semicolon.
Program 01
Program 02
Program – 03(part-1)
Program – 03(part-2)

Mais conteúdo relacionado

Mais procurados

7th Math (C2) - L58--March13
7th Math (C2) - L58--March137th Math (C2) - L58--March13
7th Math (C2) - L58--March13jdurst65
 
Discrete_Matrices
Discrete_MatricesDiscrete_Matrices
Discrete_Matricesguest78c418
 
Order Of Operations
Order Of OperationsOrder Of Operations
Order Of Operationsgemmabean
 
8th alg -l5.1
8th alg -l5.18th alg -l5.1
8th alg -l5.1jdurst65
 
Lesson 4 b special matrix multiplication
Lesson 4 b  special matrix multiplicationLesson 4 b  special matrix multiplication
Lesson 4 b special matrix multiplicationJonathan Templin
 
Unit 5 quiz review
Unit 5 quiz reviewUnit 5 quiz review
Unit 5 quiz reviewmlabuski
 
7th math c2 -l26
7th math c2 -l267th math c2 -l26
7th math c2 -l26jdurst65
 
October 21. 2014
October 21. 2014October 21. 2014
October 21. 2014khyps13
 
2.6 division of real numbers day 2
2.6 division of real numbers   day 22.6 division of real numbers   day 2
2.6 division of real numbers day 2bweldon
 
Str8ts Weekly Extreme #47 - Solution
Str8ts Weekly Extreme #47 - SolutionStr8ts Weekly Extreme #47 - Solution
Str8ts Weekly Extreme #47 - SolutionSlowThinker
 
Ix536 unit 3 pp learning object
 Ix536 unit 3 pp learning object Ix536 unit 3 pp learning object
Ix536 unit 3 pp learning objectHaroldLewis10
 
Aae oop xp_05
Aae oop xp_05Aae oop xp_05
Aae oop xp_05Niit Care
 
002#pedagogy math test
002#pedagogy math test002#pedagogy math test
002#pedagogy math testAbdul ghafoor
 
2.2 multply and divide mixed numbers 3
2.2 multply and divide mixed numbers 32.2 multply and divide mixed numbers 3
2.2 multply and divide mixed numbers 3gheovani
 
Lesson 15
Lesson 15Lesson 15
Lesson 15NRWEG3
 
Lattice Multiplication
Lattice MultiplicationLattice Multiplication
Lattice MultiplicationKevin Cummins
 

Mais procurados (20)

7th Math (C2) - L58--March13
7th Math (C2) - L58--March137th Math (C2) - L58--March13
7th Math (C2) - L58--March13
 
Discrete_Matrices
Discrete_MatricesDiscrete_Matrices
Discrete_Matrices
 
Paper3a puertollano
Paper3a puertollanoPaper3a puertollano
Paper3a puertollano
 
power and exponents
power and exponents power and exponents
power and exponents
 
Order Of Operations
Order Of OperationsOrder Of Operations
Order Of Operations
 
8th alg -l5.1
8th alg -l5.18th alg -l5.1
8th alg -l5.1
 
Shape logic 1
Shape logic 1Shape logic 1
Shape logic 1
 
Lesson 4 b special matrix multiplication
Lesson 4 b  special matrix multiplicationLesson 4 b  special matrix multiplication
Lesson 4 b special matrix multiplication
 
Unit 5 quiz review
Unit 5 quiz reviewUnit 5 quiz review
Unit 5 quiz review
 
7th math c2 -l26
7th math c2 -l267th math c2 -l26
7th math c2 -l26
 
October 21. 2014
October 21. 2014October 21. 2014
October 21. 2014
 
2.6 division of real numbers day 2
2.6 division of real numbers   day 22.6 division of real numbers   day 2
2.6 division of real numbers day 2
 
Str8ts Weekly Extreme #47 - Solution
Str8ts Weekly Extreme #47 - SolutionStr8ts Weekly Extreme #47 - Solution
Str8ts Weekly Extreme #47 - Solution
 
Ix536 unit 3 pp learning object
 Ix536 unit 3 pp learning object Ix536 unit 3 pp learning object
Ix536 unit 3 pp learning object
 
Aae oop xp_05
Aae oop xp_05Aae oop xp_05
Aae oop xp_05
 
002#pedagogy math test
002#pedagogy math test002#pedagogy math test
002#pedagogy math test
 
2.2 multply and divide mixed numbers 3
2.2 multply and divide mixed numbers 32.2 multply and divide mixed numbers 3
2.2 multply and divide mixed numbers 3
 
Lesson 15
Lesson 15Lesson 15
Lesson 15
 
Lattice Multiplication
Lattice MultiplicationLattice Multiplication
Lattice Multiplication
 
Sets copy
Sets   copySets   copy
Sets copy
 

Destaque (20)

C# Arrays
C# ArraysC# Arrays
C# Arrays
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
C++ programming
C++ programmingC++ programming
C++ programming
 
Object Oriented Program
Object Oriented ProgramObject Oriented Program
Object Oriented Program
 
C++11
C++11C++11
C++11
 
Flow control in c++
Flow control in c++Flow control in c++
Flow control in c++
 
C++ revision tour
C++ revision tourC++ revision tour
C++ revision tour
 
Flow of Control
Flow of ControlFlow of Control
Flow of Control
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
Stacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti AroraStacks & Queues By Ms. Niti Arora
Stacks & Queues By Ms. Niti Arora
 
Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++Revision notes for exam 2011 computer science with C++
Revision notes for exam 2011 computer science with C++
 
Flow of control ppt
Flow of control pptFlow of control ppt
Flow of control ppt
 
C++ classes
C++ classesC++ classes
C++ classes
 
C++ Function
C++ FunctionC++ Function
C++ Function
 
FUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPTFUNCTIONS IN c++ PPT
FUNCTIONS IN c++ PPT
 
Arrays
ArraysArrays
Arrays
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
functions of C++
functions of C++functions of C++
functions of C++
 
Data types
Data typesData types
Data types
 

Semelhante a C++ arrays part2 (20)

Variables in matlab
Variables in matlabVariables in matlab
Variables in matlab
 
Arrays
ArraysArrays
Arrays
 
Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
Array i imp
Array  i impArray  i imp
Array i imp
 
Arrays 06.ppt
Arrays 06.pptArrays 06.ppt
Arrays 06.ppt
 
About Array
About ArrayAbout Array
About Array
 
Lecture17 arrays.ppt
Lecture17 arrays.pptLecture17 arrays.ppt
Lecture17 arrays.ppt
 
Python Programming unit4.pdf
Python Programming unit4.pdfPython Programming unit4.pdf
Python Programming unit4.pdf
 
Ch8 Arrays
Ch8 ArraysCh8 Arrays
Ch8 Arrays
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
PPt. on An _Array in C
PPt. on An _Array in CPPt. on An _Array in C
PPt. on An _Array in C
 
Mesics lecture 8 arrays in 'c'
Mesics lecture 8   arrays in 'c'Mesics lecture 8   arrays in 'c'
Mesics lecture 8 arrays in 'c'
 
Vectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptxVectormaths and Matrix in R.pptx
Vectormaths and Matrix in R.pptx
 
Array 2 hina
Array 2 hina Array 2 hina
Array 2 hina
 
UNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptxUNIT-5_Array in c_part1.pptx
UNIT-5_Array in c_part1.pptx
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
Segment tree
Segment treeSegment tree
Segment tree
 
R data-structures-3
R data-structures-3R data-structures-3
R data-structures-3
 

Mais de Subhasis Nayak

Mais de Subhasis Nayak (19)

Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)Php, mysq lpart5(mysql)
Php, mysq lpart5(mysql)
 
working with database using mysql
working with database using mysql working with database using mysql
working with database using mysql
 
Php, mysq lpart3
Php, mysq lpart3Php, mysq lpart3
Php, mysq lpart3
 
Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)
 
Jsp 01
Jsp 01Jsp 01
Jsp 01
 
Jsp 02(jsp directives)2003
Jsp 02(jsp directives)2003Jsp 02(jsp directives)2003
Jsp 02(jsp directives)2003
 
Php, mysq lpart1
Php, mysq lpart1Php, mysq lpart1
Php, mysq lpart1
 
Php, mysqlpart2
Php, mysqlpart2Php, mysqlpart2
Php, mysqlpart2
 
C:\fakepath\jsp01
C:\fakepath\jsp01C:\fakepath\jsp01
C:\fakepath\jsp01
 
Servlet & jsp
Servlet  &  jspServlet  &  jsp
Servlet & jsp
 
J2ee connector architecture
J2ee connector architectureJ2ee connector architecture
J2ee connector architecture
 
how to create object
how to create objecthow to create object
how to create object
 
Pointer in c++ part3
Pointer in c++ part3Pointer in c++ part3
Pointer in c++ part3
 
Pointer in c++ part2
Pointer in c++ part2Pointer in c++ part2
Pointer in c++ part2
 
Pointer in c++ part1
Pointer in c++ part1Pointer in c++ part1
Pointer in c++ part1
 
C++ arrays part1
C++ arrays part1C++ arrays part1
C++ arrays part1
 
Introduction to network
Introduction to networkIntroduction to network
Introduction to network
 
Oops And C++ Fundamentals
Oops And C++ FundamentalsOops And C++ Fundamentals
Oops And C++ Fundamentals
 
Text mode Linux Installation Part 01
Text mode Linux Installation Part 01Text mode Linux Installation Part 01
Text mode Linux Installation Part 01
 

C++ arrays part2

  • 1. Arrays part -2 Author – Subhasis Nayak
  • 3. Multidimensional arrays • Arrays can, however, get multidimensional too. • We can create an array of any number of dimensions, and that is what makes multidimensional arrays an interesting topic from mathematical points of view.
  • 4. Declaring multidimensional array • Each dimension in an array is represented as a subscript in the array. Hence for – Two-dimensional array has two subscripts – three-dimensional array has three subscripts – & so on int twoDi_array[2][2];
  • 5. Continue ….. • Keep in mind – first subscript = rows – Second subscript = columns int twoDi_array[2][2];
  • 6. Positions 0 1 0 00 01 1 10 11
  • 7. Example chess board • Board[8][8]; 00 01 02 03 04 05 06 07 10 20 30 40 50 60 70
  • 8. Initializing Multidimensional Arrays • Initialization can be done as for uni dimensional array – Int Array[5][3] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }; 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
  • 9. Continue ….. • For sake of clarity and readability we can write like this way also 1 2 3 – int Array[5][3] = { {1,2,3}, 4 5 6 {4,5,6}, 7 8 9 {7,8,9}, 10 11 12 {10,11,12}, 13 14 15 {13,14,15} };
  • 10. • The compiler ignores the inner braces, but they do make it easier to understand how the numbers are distributed. • When initializing elements of an array, each value must be separated by a comma, with-out regard to the braces. • The entire initialization set must be within braces & it must end with a semicolon.