Index
1. Introduction to C++ 2. Datatypes in C++ 3. Variables in C++ 4. Control Statements in C++ 5. Switch Statements in C++ 6. Pointers in C++ 7. Functions in C++ 8. Call by value and Call by Reference in C++ 9. Array in C++ 10. 2d arrays in C++ 11. Classes and Objects in C++ 12. Static Functions in C++ 13. Constructor and Destructor in C++ 14. Copy Constructor in C++ 15. Friend Functions in C++ 16. Inline Functions in C++ 17. this Pointer in C++ 18. Inheritance in C++ 19. Types of Inheritance in C++ 20. Polymorphism in C++ 21. Templates in C++Classes and Objects in C++
C++ Multi-Dimensional Arrays
MultiDimensions word itself says there will be an array with mutiple dimensions(rows and columns). The simplest form of multiple Dimensions is "Two Dimensional Array".
Syntax :-
datatype arrayName[rows][coulmns];
Examples of Multi-Dimensional arrays
/* Two Dimensional Array */ int val = a[2][3]; /* Three Dimensional Array */ int val = a[2][3][4]; Here, a[2][3] = 2 rows , 3 columns. a[2][3][4] = 2 rows in outer array. Inside it 3 rows, 4 columns.
Program
#include > using namespace std; int main () { // an array with 3 rows and 2 columns. int a[3][2] = { {0,0}, {1,2}, {2,4}}; // output each array element's value. for ( int i = 0; i < 3; i++ ) for ( int j = 0; j < 2; j++ ) { cout << "a[" << i << "][" << j << "]: "; cout << a[i][j]<< endl; } return 0; }
Output :-
a[0][0]: 0 a[0][1]: 0 a[1][0]: 1 a[1][1]: 2 a[2][0]: 2 a[2][1]: 4Previous Next

NEWSLETTER
Coding Bytes by Codzify
Welcome to Coding Bytes, your weekly source for the latest coding tutorials and insights in small byte sized content.
Join 798+ Subscribers
Subscribe on LinkedInMonetize your Passion Today!
Join Codzify Affiliate Program, Earn 30% Commission on Course Sales, Get ₹449.7 or $5.41 per course Sale! No Follower Requirement. Monetize Your Passion Today!
Register NOW!Codzify Youtube Channel
Ready to level up your Full Stack App development Skills? Check out Codzify Youtube Channel for interatcive video content.
Subscribe Codzify