Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer the following question regarding the Code: int main() { FILE* infile; int altitude[4]{}, mix_ratio[4], list = 0, i, sum_altitude = 0, sum_ratio = 0,

Answer the following question regarding the Code:

int main() { FILE* infile; int altitude[4]{}, mix_ratio[4], list = 0, i, sum_altitude = 0, sum_ratio = 0, pow_altitude = 0, sum_altitude_ratio = 0; double m = 0, b = 0;

infile = fopen("zone.txt", "r"); //open file

if (infile == 0) //closes program if file not found { printf("file not found"); } else { while (!feof(infile)) //program continues { fscanf(infile, "%ld %ld", &altitude[list], &mix_ratio[list]); // gathers data from the file

list++; } for (i = 0; i < list; i++) { sum_altitude += altitude[i]; // adds sum_ratio += mix_ratio[i]; // adds pow_altitude += pow(altitude[i], 2); //adds values to the power of 2 sum_altitude_ratio += altitude[i] * mix_ratio[i]; // adds altitudes and ratios while multypling them } m = ((sum_altitude * sum_ratio - (list) * sum_altitude_ratio) / (pow(sum_altitude, 2) - (list) * pow_altitude)); b = ((sum_altitude * sum_altitude_ratio - pow_altitude * sum_ratio) / (pow(sum_altitude, 2) - (list) * pow_altitude));

printf("Range of altitudes in km: %ld to %ld ", altitude[0], altitude[3]); printf(" Linear Model: ozone-mix-ratio = %.2f * altitude + %.2f ", m, b);

} return(0);

How much memory is needed to store the data?

Time complexity:

1. What is f(n) for this program? 2. Show f(n) <= O(g(n))

The zone.txt only contains the following:

20 3 24 4 26 5 28 6

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

Describe the major regulations governing HRM practices.

Answered: 1 week ago

Question

5. To determine the financial benefits and costs of the program.

Answered: 1 week ago