Use the following array of 8 integers to answer the following questions, {7,3,7,7,7,5,2,7} a) You are required to write a user defined C++ function that will receive the above array as a parameter, and will loop through it and re-arrange it into the following final output {5,3,2,7,7,7,7,7} and display it from the main function of your program. The idea is to position all values equal to 7 in the array to come after the other values not equal to 7. The order of the other values i.e 5, 3 and 2 does not matter as long as they appear positioned before all 7s as illustrated in the hint below: Initial array: {7,3,7,7,7,5,2,7} NumbertoMove = 7 Final Array: {5,3,2,7,7,7,7,7} b) Write another separate function in the same program above that takes the array above,{7,3,7,7,7,5,2,7} and loops through the elements calculating the sum and product of all the elements and displays them.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 44SA
icon
Related questions
Question
100%

Use the following array of 8 integers to answer the following questions,
{7,3,7,7,7,5,2,7}
a) You are required to write a user defined C++ function that will receive
the above array as a parameter, and will loop through it and re-arrange it
into the following final output {5,3,2,7,7,7,7,7} and display it from
the main function of your program.
The idea is to position all values equal to 7 in the array to come after the
other values not equal to 7. The order of the other values i.e 5, 3 and 2
does not matter as long as they appear positioned before all 7s as
illustrated in the hint below:
Initial array: {7,3,7,7,7,5,2,7}
NumbertoMove = 7
Final Array: {5,3,2,7,7,7,7,7}
b) Write another separate function in the same program above that takes the
array above,{7,3,7,7,7,5,2,7} and loops through the elements
calculating the sum and product of all the elements and displays them.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Types of Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr