#include<stdio.h>
#include<stdlib.h>
int main(){
FILE *fp;
fp = fopen("tanks.dat","r");
if (!fp){
printf("File is not present");
}
else{
float width[100],height[100],depth[100];
int nol;// no of lines in the file for the tripplet
values
float wid,he,dep;
int i=0,j=0,k,result;
fscanf(fp,"%d",&nol); // reads the first line in
the file
// this while loop is to iterate over the file and get
the triplet values
while(1){
result = fscanf(fp,"%f %f
%f\n",&wid,&he,&dep);
if (result == EOF) //it checks for
end of the file it will break when we came to end of file
break;
width[j] = wid; //store the values into respective arrays
height[j] = he;
depth[j] = dep;
j++;
}
// for printing values
printf("------------the values of widths are------
\n");
for (k=0;k<nol;k++){
printf("%f\n",width[k]);
}
printf("------------the values of heights are------ \n");
for (k=0;k<nol;k++){
printf("%f\n",height[k]);
}
printf("------------the values of depths are------ \n");
for (k=0;k<nol;k++){
printf("%f\n",depth[k]);
}
}
return 0;
}
Question 9 [13 marks] A file called tanks.dat consists of the width, height and depth values for a number of water...