What code should I write to meet this last requirement. const int ARRAY_SIZE = 8; set[ARRAY_SIZE] = { -2, -11, -28, -3,

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

What code should I write to meet this last requirement. const int ARRAY_SIZE = 8; set[ARRAY_SIZE] = { -2, -11, -28, -3,

Post by answerhappygod »

What code should I write to meet this lastrequirement.
const int ARRAY_SIZE = 8; set[ARRAY_SIZE] = { -2, -11, -28, -3,-9, -6, -10, -20 }; Testing -> highestElement(set,ARRAY_SIZE)
Test feedback highestElement() incorrectly returned 0
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 1
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 1 (108.45 KiB) Viewed 31 times
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 2
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 2 (159.95 KiB) Viewed 31 times
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 3
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 3 (102.91 KiB) Viewed 31 times
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 4
What Code Should I Write To Meet This Last Requirement Const Int Array Size 8 Set Array Size 2 11 28 3 4 (22.35 KiB) Viewed 31 times
A copy of Pr7-19.cpp has been added as a template in your program window. The program produces the output as shown in Figure 1. Figure 1: The arrays values are: 1 2 3 4 5 6 7 After calling doubleArray the values are: 2 4 6 8 10 12 14 • Add a function with the following prototype: int highestElement(int [], int); the function highestElement () should find and return the highest element of the array. Hint: You may consult slide 3 of Module 7, Lesson 1-> CS1336_Lect7c_Arrays_Compare_Parallel.pptx for sample code that finds the highest value in an array. • Call the highestElement () function after showValues () is called at line 25. The return value from the function can be saved in a variable. Another option is to embed the function call (which will return the highest element) in the cout statement that prints the highest element in the specified format. Your program should produce output as shown in Figure 2. Figure 2: The arrays values are: 1 2 3 4 5 6 7 After calling doubleArray the values are: 2 4 6 8 10 12 14 The highest element in the array is 14
4 #include 5 using namespace std; 6 7 // Function prototypes 8 void doubleArray (int [], int); 9 void showValues (int [], int); 10 int highestElement(int [], int); 11 12 int main() 13 { 14 const int ARRAY_SIZE = 7; int set [ARRAY_SIZE] = {1, 2, 3, 4, 5, 6, 7}; 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30} 31 32 33 // Definition of function doubleArray 34 // This function doubles the value of each element 35 // in the array passed into nums. The value passed 36 // into size is the number of elements in the array. 37 //** // Display the initial values. cout << "The arrays values are: \n"; showValues (set, ARRAY_SIZE); // Double the values in the array. doubleArray (set, ARRAY_SIZE); // Display the resulting values. cout << "After calling doubleArray the values are: \n"; showValues (set, ARRAY_SIZE); cout<<"The highest element in the array is "< max) { max nums [index]; ************ } int max = 0; for (int index = 0; index < size; index++) { } return max; * ************** *
4: Unit test ▲ const int ARRAY_SIZE = 8; set[ARRAY_SIZE] = {-2, -11, -28, -3, -9, -6, -10, -20 }; Testing -> highestElement(set, ARRAY_SIZE) Test feedback highestElement() incorrectly returned 0 0/3
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply