Problem 3 (30 Points) The following main function of a C++ program calls the function mirror...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Problem 3 (30 Points) The following main function of a C++ program calls the function mirror that mirrors the content of a pre-initialized array v of integers and then display the contents of the mirrored array. int main() { // Declare array int v[] = {5, 6, 7, 8, 2, 1}; // Mirror it mirror(v, 6); // Print array for (int i = 0; i < 6%; i++) cout < < v[i] < < ' '; return 0; } Implement the function mirror in C++. The function must work with any array of integers where the array size can be either odd or even. Examples of arrays mirror for both odd and even number of elements are shown below: 0 ' 2 3 4 5 6 7 8 2 R 1 2 3 4 5 7 & 2 ' Odd number of elements Problem 4 (40 Points) Even number elements Write a C++ program that takes as inputs from a teacher, the names of her/his students along with the grade of each student in an exam. Define a struct with two fields: Name and Grade. Create an array of this struct to store the students' data. All grades are integers that have to be in the range from 0 to 100 (inclusive). At the beginning, you will need to ask the teacher for the size of the class (the number of students) and use dynamic memory to create the array. The program will display (its outputs) the following: 1. The complete list of students along with their grades in a descending order of the grades. 2. The average and range of the students' grades. 3. The name of the student with the maximum grade and displays this grade. 4. The name of the student with the minimum grade and displays this grade. Each of the above four set of outputs must be implemented in a separate function where the array is passed to these functions as a parameter. Do not use any global variables in your program. Problem 3 (30 Points) The following main function of a C++ program calls the function mirror that mirrors the content of a pre-initialized array v of integers and then display the contents of the mirrored array. int main() { // Declare array int v[] = {5, 6, 7, 8, 2, 1}; // Mirror it mirror(v, 6); // Print array for (int i = 0; i < 6%; i++) cout < < v[i] < < ' '; return 0; } Implement the function mirror in C++. The function must work with any array of integers where the array size can be either odd or even. Examples of arrays mirror for both odd and even number of elements are shown below: 0 ' 2 3 4 5 6 7 8 2 R 1 2 3 4 5 7 & 2 ' Odd number of elements Problem 4 (40 Points) Even number elements Write a C++ program that takes as inputs from a teacher, the names of her/his students along with the grade of each student in an exam. Define a struct with two fields: Name and Grade. Create an array of this struct to store the students' data. All grades are integers that have to be in the range from 0 to 100 (inclusive). At the beginning, you will need to ask the teacher for the size of the class (the number of students) and use dynamic memory to create the array. The program will display (its outputs) the following: 1. The complete list of students along with their grades in a descending order of the grades. 2. The average and range of the students' grades. 3. The name of the student with the maximum grade and displays this grade. 4. The name of the student with the minimum grade and displays this grade. Each of the above four set of outputs must be implemented in a separate function where the array is passed to these functions as a parameter. Do not use any global variables in your program.
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
Debug the given C program to read and print N array elements. Find 10 errors in the given Code and correct the errors. (5Marks) NOTE: Copy and PASTE the correct program in the space below. /*Arrays...
-
What precautions would you take in machining with brittle tool materials, especially ceramics? Explain.
-
On July 31, Arthur Company's Cash in Bank account had a balance of \(\$ 8,112.62\). On that date, the bank statement indicated a balance of \(\$ 10,170.62\). A comparison of returned checks and bank...
-
Matt Lehti owns the Zap Record Shop. He is in the process of examining the following performance report: Matt is very pleased that the company had favorable variances for sales and income. However,...
-
The audit report provides reasonable assurance that the financial statements are free from material misstatements. The auditor is put in a difficult situation because materiality is defined from a...
-
https://waldenu.instructure.com/users/2102/files/4325499?wrap=1&verifier=XG3VLdq2wD1UFdmQV9ApXN4UeY8dLY2UlmTAudwXBased on the dataset you chose, construct a research questionthat can be answere 0...
-
Suppose $ = $100, K = $90 and an American option has a value C = $12. Since C>= max(S-K, 0), is there an arbitrage opportunity? If so, how do you exploit it?
-
SJW Financial Services has its headquarters in Nanaimo, British Columbia. The City of Nanaimo assesses property taxes on June 30 annually and notifies property owners electronically. Property taxes...
-
Mercury Motors has 20,000 shares of 6%, $50 par value, cumulative preferred stock. The preferred stock had been issued in 2012 and is still outstanding at year-end December 2021. As of the December...
-
A large positively charged object with charge 9+ = 4.75 C is brought near a negatively charged plastic ball suspended from a string of negligible mass. The suspended ball has a charge of q = -48.3 nC...
-
A company began January with 6,000 units of its principal product. The cost of each unit is $6. Inventory transactions for the month of January are as follows: Date of Purchase Units Purchases Unit...
-
Panamint Systems Corporation is estimating activity costs associated with producing disk drives, tapes drives, and wire drives. The indirect labor can be traced to five separate activity pools. The...
-
Outline the reasons of failure of the woman's united soccer association and the woman's professional soccer league in the case study "the national woman's soccer league and commissioner Lisa Baird:...
-
Discuss the concept of the looking-glass self. how do you think others perceive you? do you think most people perceive you correctly?
-
\(45-6 \times 7^{3}\) Perform the indicated calculation.
-
\(72 \div 6+18\) Perform the indicated calculation.
-
\(6^{2} \times 5-13 \times 9^{2}\) Perform the indicated calculation.
Study smarter with the SolutionInn App