Question
Study the program, answer the questions. The company array contains the amounts the company sold both domestically and internationally during the months of January through
Study the program, answer the questions. The company array contains the amounts the company sold both domestically and internationally during the months of January through June. The first row contains the domestic sales for the six months. The second row contains the international sales during the same period.
1. What value is stored in the company[1][5] element?
2. How can you calculate the total company sales made in February?
3. What is the highest row subscript in the company array? What is the highest column subscript in the array?
4. If the January domestic sales are stored in the company[0][0] element, where are the January international sales stored?
5. If you change the for clause in Line 16 to for (int month = 1; month <= 6; month += 1), how will the change affect the assignment statement in the for loop?
6. Run the program. The total company sales are $643900.
7. Modify the program so that it displays the total domestic sales, total international sales, and total company sales. Save and then run the program. (The total domestic sales are $345500.) Take a print screen of the output screen and copy the code and paste bother here.
8. Next, modify the program so that it also displays the total sales made in each month. Save and then run the program. (The total January sales are $115000.) Take a print screen of the output screen and copy the code and paste bother here.
Program:
//Lab - calculates the total company sales
#include "stdafx.h" #include
int main() { int company[2][6] = { { 75000, 30200, 67800, 45000, 60000, 67500 }, { 40000, 75000, 64000, 32600, 47800, 39000 } }; int companySales = 0;
for (int location = 0; location < 2; location += 1) for (int month = 0; month < 6; month += 1) companySales += company[location][month]; //end for //end for cout << "Company sales: $" << companySales << endl; return 0; }//end of main function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started