0% found this document useful (0 votes)
5 views1 page

3D Array Input and Display Example

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

3D Array Input and Display Example

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <stdio.

h>

int main()
{
int z, x, y;

printf("Enter the no. of rows for each array you want: ");
scanf("%d", &x);
printf("Enter the no. of columns for each array you want: ");
scanf("%d", &y);
printf("Enter the no. of levels you want: ");
scanf("%d", &z);

int arr[z][x][y];

printf("\nINSERT ELEMENTS OF THE 3D ARRAY\n");


for (int i = 0; i < z; i++)
{
for (int j = 0; j < x; j++)
{
for (int k = 0; k < y; k++)
{
printf("Enter the value of the element at index (%d, %d, %d):
", i, j, k);
scanf("%d", &arr[i][j][k]);
}
}
}

printf("\nTHE 3D ARRAY\n");
for (int i = 0; i < z; i++)
{
for (int j = 0; j < x; j++)
{
for (int k = 0; k < y; k++)
{
printf("%d ", arr[i][j][k]);
}
printf("\n");
}
printf("\n \n");
}
return 0;
}

You might also like