1.) If the dimension for array temperature is 7 rows and 2 columns, how many instances the inner loop iterates? How about the outer loop?   2.) How was it made it possible for the program to determine the average high temperature and average low temperature?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

*Try to run the program in c++ then answer the questions below*

 

PROGRAM:

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
int temp [7][2];
int high_temp, low_temp;
double total_high = 0.0, total_low = 0.0, avg_high = 0.0, avg_low = 0.0;

cout << "\t===========================";
cout << "\n\tDay Highest Lowest\n";
cout << "\t===========================";
cout << endl <<endl;

for(int row = 0; row < 7; row += 1)
{
for (int col = 0; col < 2; col += 1)
{
if (col == 0)
{
cout << "\t " << row +1 << "\t";
cin >> temp [row][col];
}
else
{
cin >> temp [row][col];
}
}
}

cout << "\n\t===========================";
cout << endl << "\t";
high_temp = temp [0][0];
low_temp = temp [0][1];

for (int col = 0; col < 2; col ++)
{
for (int row = 0; row < 7; row ++)
{
if ((col == 0) && (temp [row][col] > high_temp))
high_temp = temp [row][col];

if ((col == 1) && (temp [row][col] <low_temp))
low_temp = temp [row][col];

if (col == 0)
total_high = total_high + temp[row][col];

if (col == 1)
total_low = total_low + temp[row][col];
}

if (col == 0)
{
avg_high = total_high / 7.0;

cout <<fixed;
cout <<setprecision (2);
cout << "\n\tThe average high temperature: "
<< avg_high <<endl;
}

else
{
avg_low = total_low / 7.0;

cout <<fixed;
cout <<setprecision (2);
cout << "\n\tThe average high temperature: "
<< avg_low <<endl <<endl;
}
}

return 0;
}

 

QUESTIONS:

1.) If the dimension for array temperature is 7 rows and 2 columns, how many instances the inner loop iterates? How about the outer loop?

 

2.) How was it made it possible for the program to determine the average high temperature and average low temperature?

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY