data-structure-C

3D Matrix Manipulation in C

This program implements the allocation, filling, printing, and deallocation of a dynamically allocated three-dimensional matrix in C.

Program Structure

The program follows these steps:

  1. Reading Dimensions: The user inputs the X, Y, and Z sizes of the matrix.
  2. Dynamic Allocation: The matrix is dynamically allocated in memory.
  3. Matrix Filling: The user enters values for each matrix position.
  4. Matrix Printing: The matrix is displayed on the screen.
  5. Memory Deallocation: The allocated memory is properly freed to prevent leaks.

Implemented Functions

How to Run

  1. Compile the code using a C compiler:
    gcc array.c -o array
    
  2. Run the program:
    ./array
    
  3. Enter the required values when prompted.

Example Input and Output

Input:

Enter dimension X: 2
Enter dimension Y: 2
Enter dimension Z: 2
x: 0, y: 0, z: 0    1
x: 0, y: 0, z: 1    2
x: 0, y: 1, z: 0    3
x: 0, y: 1, z: 1    4
x: 1, y: 0, z: 0    5
x: 1, y: 0, z: 1    6
x: 1, y: 1, z: 0    7
x: 1, y: 1, z: 1    8

Output:

1 	2 
3 	4 

5 	6 
7 	8 

Considerations