Question

Question 9 [13 marks] A file called tanks.dat consists of the width, height and depth values for a number of water tanks. The
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#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;
}

Add a comment
Know the answer?
Add Answer to:
Question 9 [13 marks] A file called tanks.dat consists of the width, height and depth values for a number of water...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • QUESTION 1 (15 marks) Studd Enterprises sells big-screen televisions. A concern of management is the number...

    QUESTION 1 (15 marks) Studd Enterprises sells big-screen televisions. A concern of management is the number of televisions sold each day. A recent study revealed the number of days that a given number of televisions were sold. # of TV units sold #of days Answer the questions below. For each part, show your calculations and/or explain briefly how you arrived at your answer, as appropriate or needed. Required: a. Convert the frequency distribution above into a probability distribution (or relative...

  • Question 3 A 10 m square and 7.5 m deep pit is to be excavated in...

    Question 3 A 10 m square and 7.5 m deep pit is to be excavated in a soil with a unit weight of 20 kN/m2. What is the stress relief at 2 m. 5 m and 10 m below the centre point of the bottom of the excavation? b. The circular flexible area is uniformly loaded (q 320 kN/m2). Determine the change in vertical stress: i. at point A At a point 2 m below point A 4 m A...

  • Python Pandas, Series and DataFrame Question (NO Loops, No If Statements, No List Comprehensions) The file...

    Python Pandas, Series and DataFrame Question (NO Loops, No If Statements, No List Comprehensions) The file bank.csv contains data about bank customers. The last column ('Personal Loan') indicates whether or not the customer was approved for a personal loan or not. Write a function named loan_by_zip that accepts 3 parameters: a file name, a minimum number of records, and a percentage approval rate. The function should return a DataFrame of those zip codes for which we meet the minimum number...

  • Question 3 (9 marks) Consider the following information about a non-dividend paying stock: The current stock...

    Question 3 (9 marks) Consider the following information about a non-dividend paying stock: The current stock price is $36, and its return standard deviation is 30% per year. The continuous compound risk-free rate is 3% per year. Assume that the Black-Scholes model correctly prices all the options written on the stock given the information above. a). A call option written on the stock expires in 1 year and has an exercise price of $36. Calculate the Black-Scholes value of the...

  • Question No: 3 (a) A factory produces 2.5% of defective items.If a sample of 200 items...

    Question No: 3 (a) A factory produces 2.5% of defective items.If a sample of 200 items is taken at random from the production. What is the probability that there will be at least four collision in a week? (2 Marks) 50,where t (b) The failure distribution function F(t) of a building system is given F(t) = 1-e is in years. Determine the following: (i) The system will last more than 6 years (ii) hazard function h(t) (3 Marks) (C) A...

  • please post ONLY flatratepackage.cpp, flateratepackage.h, package inventory.h and package inventory.cpp... Thank you! In this homework, you...

    please post ONLY flatratepackage.cpp, flateratepackage.h, package inventory.h and package inventory.cpp... Thank you! In this homework, you are going to write a program to represent various types of packages offered by package-delivery services. You need to create an inheritance hierarchy to represent various types of packages with different shipping options and associated costs. The base class is Package and the derived classes are FlatRatePackage and OvernightPackage. The base class Package includes the following attributes: • Sender information: senderName (string), senderAddress (string),...

  • could you please help me with this problem, also I need a little text so I...

    could you please help me with this problem, also I need a little text so I can understand how you solved the problem? import java.io.File; import java.util.Scanner; /** * This program lists the files in a directory specified by * the user. The user is asked to type in a directory name. * If the name entered by the user is not a directory, a * message is printed and the program ends. */ public class DirectoryList { public static...

  • summatize the following info and break them into differeng key points. write them in yojr own...

    summatize the following info and break them into differeng key points. write them in yojr own words   apartus 6.1 Introduction—The design of a successful hot box appa- ratus is influenced by many factors. Before beginning the design of an apparatus meeting this standard, the designer shall review the discussion on the limitations and accuracy, Section 13, discussions of the energy flows in a hot box, Annex A2, the metering box wall loss flow, Annex A3, and flanking loss, Annex...

  • 10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated...

    10. Write a one-page summary of the attached paper? INTRODUCTION Many problems can develop in activated sludge operation that adversely affect effluent quality with origins in the engineering, hydraulic and microbiological components of the process. The real "heart" of the activated sludge system is the development and maintenance of a mixed microbial culture (activated sludge) that treats wastewater and which can be managed. One definition of a wastewater treatment plant operator is a "bug farmer", one who controls the aeration...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT