/* example that demonstrates the use of arrays*/ #include #include int main (void) { int i,j; /* an array of integers with 6 elements */ int M[6]; /* an array of floats with initialisation */ float F[3] = {92, 23.4, 21.3}; /* Two dimensional arrays */ int twodint[4][4]; float twodfloat[4][4]; /* do something with the integer array */ for (i=0; i<6; i++) { M[i] = i*i; printf("Element %i = %i \n",i,M[i]); } /* do something with the float arrays */ for (i=0; i<3; i++) printf("F[%i] = %f\n",i,F[i]); /* manipulate the 2d integer arrays */ for (i=0; i<4; i++) { for (j=0; j<4; j++) { twodint[i][j] = i*j; printf("integers i = %i, j = %i, value = %i\n",i,j,twodint[i][j]); } } /* manipulate the 2d float arrays */ for (i=0; i<4; i++) { for (j=0; j<4; j++) { twodfloat[i][j] = i*(j*j); printf("floats i = %i, j = %i, value = %i\n",i,j,twodfloat[i][j]); } } }