In this article I would like to share with your how to write a three dimensional array in c++ also known as multidimensional array. The logic behind three dimensional array in C++ is the use of three for loop statement. In most programming problems the use of three dimensional array is rarely being used but it is a good idea to have some knowledge how write multidimensional array using C++ as our programming language.
If you have some questions regarding about my work please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.
Thank you very much and Happy Programming.
Sample Output of Our Program
Program Listing
using namespace std;
main()
{
int elements[2][2][2];
int count=1;
cout << "\n\n Three Dimentional Array";
cout << "\n\n";
for (int a=0; a<2; a++) {
for (int b=0; b<2; b++) {
for (int c=0; c<2; c++) {
cout << "Enter Values No "
<< count++
<< " : ";
cin >>elements[a][b][c];
}
}
}
cout << "\n\n";
cout << "List of Values ";
cout << "\n\n";
for (int a=0; a<2; a++) {
for (int b=0; b<2; b++) {
for (int c=0; c<2; c++) {
cout << "\n" << elements[a][b][c];
}
}
}
cout << "\n\n";
system("pause");
}
DOWNLOAD SOURCE CODE HERE
No comments:
Post a Comment