Programming & Scripting Tutorials

C++: Creating a Multidimensional Array Table





Here is the code for displaying multidimensional arrays, we will discuss it after:

#include <iostream>
using namespace std;

int main(){

	int ArrayOne[][5]={{3, 24, 55, 72, 12}, {18, 88, 7, 66, 34}};
	cout << "This is the array:" << endl;
	for(int row=0;row<2;row++){
		for(int column=0;column<5;column++){
			cout << " " << ArrayOne[row][column];
		}
	cout << endl;
	}
	system("PAUSE");
	return 0;
}

Most of this you should really understand. It's a fairly simple script, and if you wanted you could even create a function for it that accepted a multidimensional array as a parameter.

All it really does is check if there are any rows (and then columns) left to display, and if there is displays the one that its on.


This C++ tutorial was written by


Back to C++

Advertisement: