Question: Lab Exercises 1. Create a C++ program named lab1b_1.cpp which completes a function named post_4 such that when given an array of ints, post_4 returns

Lab Exercises 1. Create a C++ program named lab1b_1.cpp which completes a function named post_4 such that when given an array of ints, post_4 returns the number of elements from the array that come after the rightmost 4 in the array. The array will contain at least one 4. post_4( {2, 4, 1, 2}, 4 ) returns 2 post_4( {4, 1, 1, 4, 2}, 5 ) returns 1 post_4( {4, 4, 1, 2, 3} , 5) returns 3 post_4( {4} , 1) returns 0 // Precondition: nums contains at least one 4 int post_4(int nums[], int length) { Your main function might look like: #include using namespace std; int post_4(int nums[], int length); int main() { int ary[] = {2, 4, 1, 2}; int count = post_4(ary, 4); cout << "The number of values after the last 4: " << count << endl; return 0; } // define the function here CSS-2A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!