(a) Write C++ statements to do the following: i. ii. iii. iv. V. vi. Declare an...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Write C++ statements to do the following: i. ii. iii. iv. V. vi. Declare an object to read data from a file; Use this object to open a file named x. dat; Read input from x.dat and store it in the previously declared variable x; Declare an object to write data to a file; Use this object to open a file named sqrtx.dat; Calculate the square root of the value of x and output the result to sqrtx.dat. (6 marks) (b) Using the statements from part (a) above, write a C++ program that reads in a list of values for the variable x from x.dat and calculates √x, writing the output to sqrtx.dat. Use an appropriate loop, assume x.dat has 100 lines and, if x is negative, set √x = 0. Include the appropriate header files in your program. (13 marks) (a) Write C++ statements to do the following: i. ii. iii. iv. V. vi. Declare an object to read data from a file; Use this object to open a file named x. dat; Read input from x.dat and store it in the previously declared variable x; Declare an object to write data to a file; Use this object to open a file named sqrtx.dat; Calculate the square root of the value of x and output the result to sqrtx.dat. (6 marks) (b) Using the statements from part (a) above, write a C++ program that reads in a list of values for the variable x from x.dat and calculates √x, writing the output to sqrtx.dat. Use an appropriate loop, assume x.dat has 100 lines and, if x is negative, set √x = 0. Include the appropriate header files in your program. (13 marks)
Expert Answer:
Answer rating: 100% (QA)
include include include int main Part a i Declare an object to read data from a file stdifstream inp... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
What portion of the company's (Crocs) assets and sales has been attributed to a different line of businesses in each of the past five years ( 2018-2022) ? (For public companies, this information may...
-
Two medical supply companies in San Francisco provided oxygen to patients at home. The companies were owned by the doctors who prescribed the oxygen. These doctors made up 60 percent of the lung...
-
In 20X2, Jacque's Gardening Supply acquired Glenn's Agricultural Center and recorded goodwill in the amount of $450,000. At the end of the 20X4 year, the net assets (including goodwill) of Glenn's...
-
Graph the solution of each system given in Problems 5-18. \(\left\{\begin{array}{l}x \geq 0 \\ y \geq 0 \\ x <500 \\ y \leq 1,000\end{array}ight.\)
-
This case, based on Gildan Activewear Inc.'s balance sheet in Appendix A at the end of this book and on MyAccountingLab, will familiarize you with some of the assets and liabilities of this actual...
-
On March 31, 2018, the balances of the accounts appearing in the ledger of Royal Furnishings Company, a furniture wholesaler, are as follows: A. Prepare a multiple-step income statement for the year...
-
Mega Millions is a multistate lottery in which players try to guess the numbers that will turn up in a drawing of numbered balls. One of the balls drawn is the Mega Ball. Matching the number drawn on...
-
What is meant by the reference in Table 5.3-1 to an FAS 116 adjustment? How are contributions recorded? Is there a distinction between pledges receivable and accounts receivable? Are there...
-
Reorder level (A, B), Two components A and B are used as follows: Normal usage 130 units per week each Minimum usage 145 units per week each Maximum usage 850 units per week each Reorder Quantity A...
-
Complete Form 941 for the 4th quarter for TCLH Industries (which is located at 202 Whitmore Avenue, Durham, NC 27701; Employer Identification #44-4444444). Assume that all necessary deposits were...
-
Our scuba diver, still at a depth of 40.0 m, finds a 9.6 cm diameter cannon ball. They pick it up and then release it from a stationary point (its initial velocity is zero). At that time, what is the...
-
What is the output of the following C program? int main() { int i=5; j=j++ + ++i; printf("%d", i); return 0; }
-
Your bank has the following balance sheet: Assets Liabilities (unit in million) Reserves $50 Checkable deposits $200 Securities 50 Loans 150 Bank capital 50 b) If there is an unexpected deposit...
-
The following financial information is for Alpha Corporation for the fiscal years ending 2017 & 2016 (all balances are normal): Item/Account 2017 2016 Accounts Receivable $9,800 $9,400 Inventory...
-
During the current year, merchandise is sold for $8,560,000. The cost of the goods sold is $6,077,600. This information has been collected in the Microsoft Excel Online file. Open the spreadsheet,...
-
Under HIPAA, which is a reason for releasing or disclosing patient information? For how long a heart lung machine can be used?
-
An atom in its triplet state S is subjected to external magnetic field of 1 cm-. (Round Tesla. The splitting of the state is shifted by off to two decimal places)
-
What steps must a business take to implement a program of social responsibility?
-
Consider the reaction: If a mixture of solid nickel(II) oxide and 0.20 M carbon monoxide comes to equilibrium at 1500 K, what is the equilibrium concentration of CO 2 ? NiO(s) + CO(g) Ni(s) + CO(g) K...
-
An LP gas tank in a home barbeque contains 13.2 kg of propane, C 3 H 8 . Calculate the heat (in kJ) associated with the complete combustion of all of the propane in the tank. C3Hg(g) + 5 O2(g) 3...
-
A laser pulse with wavelength 532 nm contains 3.85 mJ of energy. How many photons are in the laser pulse?
-
Describe the five suggestions on how CPA firms can effectively implement a system of quality control.
-
Give an explanation of each of the following parts of the independent auditor's report:
-
Answer the following questions about organizations that influence operations of CPA firms. a. What is the purpose of state boards of ac- counting? b. What are state societies of certified public...
Study smarter with the SolutionInn App