Question: C++ PROGRAM: Create the function: int flip(string a[], int n); the functions you must write take 2 parameters. an array of strings a[] , and

C++ PROGRAM:

Create the function: int flip(string a[], int n);

the functions you must write take 2 parameters. an array of strings a[] , and the number of items the function will consider in the array n, starting from the beginning. Reverse the order of the elements of the array and return n. all functions that return an int must return 1 if they are passed a negative array size. passing 0 to the function as the array size is not itself an error; it merely indicates the function should examine no elements of the array. Also when we say "the array", we mean the n elements that the function is aware of. The one error your function implementations doesn't have to handle is when the caller of the function lies and says the array is bigger than it really is. Your program must not use any function templates from the algorithms portion of the Standard C++ library For example,

string folks[6] = { "bruce", "steve", "", "tony", "sue", "clark" }; int q = flip(folks, 4); // returns 4 // folks now contains: "tony" "" "steve" "bruce" "sue" "clark" 
string folks[6] = { "bruce", "steve", "", "tony", "sue", "clark" }; int q = flip(folks, 6); // returns 6 // folks now contains: "clark" "sue" "tony" "" "steve" "bruce" "sue" "clark" 
string folks[6] = { "bruce", "steve", "", "tony", "sue", "clark" }; int q = flip(folks, 0); // returns 0 // no change 
string folks[6] = { "bruce", "steve", "", "tony", "sue", "clark" }; int q = flip(folks, 25); // returns 25 // folks now contains: "clark" "sue" "tony" "" "steve" "bruce" "sue" "clark" 
string folks[6] = { "bruce", "steve", "", "tony", "sue", "clark" }; int q = flip(folks, -7); // returns -1 

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!