/* inputing values to a 2D array from a file */ #include int main() { int i, j; float values[3][4]; FILE *fptr; fptr = fopen("02_input.dat", "r"); /* input the values using nested loops */ for (i=0; i<3; i++) { for (j=0; j<4; j++) { fscanf(fptr, "%f", &values[i][j]); } } /* done with in input, close file */ fclose(fptr); /* now print out the values */ for (i=0; i<3; i++) { for (j=0; j<4; j++) { printf("%4.2f ", values[i][j]); } /* add a newline at the end of each line */ printf("\n"); } }