Write a C++ Program for Three Dimensional Array Example

By | 27.12.2016

Three Dimensional Array Example

Write a C++ Program for Three Dimensional Array Example. Here’s simple Program for Three Dimensional Array Example in C++ Programming Language.

What is an Array ?

Arrays a kind of data structure that can store a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.

Instead of declaring individual variables, such as number0, number1, …, and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and …, numbers[99] to represent individual variables. A specific element in an array is accessed by an index.

All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.

A three dimensional array can be thought of as an array of arrays of arrays.

Three dimensional array contains three for loops in programming. So, to initialize and print three dimensional array, you have to use three for loops. Third for loop (the innermost loop) forms 1D array, Second for loop forms 2D array and the third for loop (the outermost loop) forms 3D array

Here is source code of the C++ Program for Three Dimensional Array Example. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.


/* C++ Program for Three Dimensional Array Example  */

using namespace std;

int main()

        int arr[3][4][2] = {
                                 {2, 4},
                                 {7, 8},
                                 {3, 4},
                                 {5, 6}
                                 {7, 6},
                                 {3, 4},
                                 {5, 3},
                                 {2, 3}
                                 {8, 9},
                                 {7, 2},
                                 {3, 4},
                                 {5, 1}
        cout<<"\narr[0][0][0] = "<<arr[0][0][0]<<"\n";
        cout<<"\narr[0][2][1] = "<<arr[0][2][1]<<"\n";
        cout<<"\narr[2][3][1] = "<<arr[2][3][1]<<"\n";

        return 0;


/* C++ Program for Three Dimensional Array Example  */

arr[0][0][0] = 2

arr[0][2][1] = 4

arr[2][3][1] = 1

Process returned 0

Above is the source code for C++ Program for Three Dimensional Array Example which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may Contact Us through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

Thanks for reading the post….

4.8 4 votes
Article Rating
Category: Arrays Programs C++ Programming Tags:

About Tunde A

My name is Tunde Ajetomobi, a Tech Enthusiast and Growth Hacker. I enjoy creating helpful content that solves problem across different topics. Codezclub is my way of helping young aspiring programmers and students to hone their skills and find solutions on fundamental programming languages.

Notify of

Newest Most Voted
Inline Feedbacks
View all comments

do you guys have a c++ whatsapp group