/* --------------------------------------------------------------------- ** Figure 10.8: Filling an array with data. ** --------------------------------------------------------------------- */ #include #define N 3 void main( void ) { int k; /* Loop counter. */ float dimension[N]; /* Dimensions of a box. */ float volume; /* The volume of the box. */ puts( "\n Array Input Demo: the Volume of a Box" ); printf( " Please enter dimensions of box in cm when prompted.\n" ); for (k = 0; k < 3; ++k) { printf( "\t > "); scanf( "%g", &dimension[k] ); } volume = dimension[0] * dimension[1] * dimension[2] / 1e6; printf( "\t The volume of the box ( %g * %g * %g ) is %g cubic m.\n\n", dimension[0], dimension[1], dimension[2], volume ); }