Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions

Question

The paleolithic age human life, short write up ?

Answered: 1 week ago