Question
General requirements: - No global variables - No multiple return statements in one function - Show how you have tested these functions - cin and
General requirements: - No global variables - No multiple return statements in one function - Show how you have tested these functions - cin and cout are not allowed in these functions. They can only be in main() or testing functions. It should return the values to the caller through the use of return type and pass-by-reference parameters. - Please do not use struct, tuple or pair class. Please use only pass-by-reference parameters and return type to return values to the caller. - Please do not use string class - Please do not change or sort the array - Please do not use any string function such as strlen or string class and its methods. - Please do not use array notation (e.g. square bracket) Note: this is an exercise to use functions and pointers.
Question #1: Write a function named "checkListMidpoint" that accepts a pointer to an array of integers, its size and the midpoint value (integer). The function will check the list of numbers in the array and return true if numbers of array elements above the midpoint value is the same as the number of elements below that value, how many numbers are exactly equal the midpoint. Requirement: please use only pointer notation in the function. No array notation (e.g. do not use square bracket).
For example, the following arrays with given the midpoint value of 20 int numList0[] = {10} ; // will return false and 0 int numList1[] = {10, 20, 40} ; // will return true and 1 int numList2[] = {0, 40, 30, 20, 10, 20} ; // will return true and 2 int numList3[] = {40, 30, 20} ; // will return false and 1 int numList4[] = {40, 10} ; // will return true and 0
Question #2: Write a function named "replaceBlanks" that accepts a pointer to a C-string (an array of characters with a NULL terminating character) and it will replace all blanks in that C-string array with question mark ('?'). It will return three values: - the number of blanks that it has replaced with '?' - the number of '?' that was already in the C-string - the boolean flag that is true if after replacement, the C-string is all '?' and false otherwise.
For example, here are examples of C-string and its expected return values "One Two Three" will become "One?Two?Three" and it will return 2 blanks, 0 question mark and false "? ? " will become "????" and it will return 2 blanks, 2 question marks and true " " will become "?" and it will return 1 blank, 0 question mark and true "?" will become "?" and it will return 0 blank, 1 question mark and true "1" will become "1" and it will return 0 blank, 0 question mark and false "" will become "" and it will return 0 blank, 0 question mark and false "1?" will become "1?" and it will return 0 blank, 1 question mark and false "1 " will become "1?" and it will return 1 blank, 0 question mark and false
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started