Fill random value to a multidimensional array - C Array

C examples for Array:Multidimensional Arrays

Description

Fill random value to a multidimensional array

Demo Code

#include <stdio.h>
#include <stdlib.h>

int random_array[10][10][10];
int a, b, c;//  w  ww. ja v a  2  s . c  o  m

int main( void )
{
    for (a = 0; a < 10; a++){
        for (b = 0; b < 10; b++){
            for (c = 0; c < 10; c++){
                random_array[a][b][c] = rand();
            }
        }
    }
    for (a = 0; a < 10; a++)
    {
        for (b = 0; b < 10; b++)
        {
            for (c = 0; c < 10; c++)
            {
                printf("\nrandom_array[%d][%d][%d] = ", a, b, c);
                printf("%d", random_array[a][b][c]);
            }
        }
    }
    return 0;
}

Result


Related Tutorials