Successfully reported this slideshow.
Upcoming SlideShare
×

# C++ arrays part2

1,225 views

Published on

Hi friends these array series presentation gives you clear cut knowledge in array in c++ programming, array in c++ tutorial, array in c++ syntax, array in c++ example

• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

### C++ arrays part2

1. 1. Arrays part -2 Author – Subhasis Nayak
2. 2. Do & Don’t
3. 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. 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. 5. Continue ….. • Keep in mind – first subscript = rows – Second subscript = columns int twoDi_array[2][2];
6. 6. Positions 0 1 0 00 01 1 10 11
7. 7. Example chess board • Board[8][8]; 00 01 02 03 04 05 06 07 10 20 30 40 50 60 70
8. 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. 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. 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.
11. 11. Program 01
12. 12. Program 02
13. 13. Program – 03(part-1)
14. 14. Program – 03(part-2)