Question: CODE IN C++ General requirements: - No global variables - No multiple return statements in one function - Show how you have tested these functions

CODE IN C++

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 function. 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 Note: this is an exercise to use functions, arrays and C-string which is an array of characters with NULL terminated character.

Question #1: Write a function named "findTheLargest" that accepts an array of integers and its size. It will return three different values: - the value of the largest element in the array - the boolean value of true if the largest number in the array is the first or the last element in that array and false otherwise - the count of how many largest numbers of the same value in the array. For examples, If this is called with the array of {10}, it will return 10, true and 1. If this is called with the array of {10, 10}, it will return 10, true and 2. If this is called with the array of {10, 20, 10}, it will return 20, false and 1. If this is called with the array of {10, 20, 20, 10}, it will return 20, false and 2. If this is called with the array of {10, 5, 2, 3, 4, 10}, it will return 10, true and 2. If this is called with the array of {50, 20, 30, 40, 10}, it will return 50, true and 1. If this is called with the array of {10, 30, 40, 10}, it will return 40, false and 1.

Question #2: Write a function named "isAcceptableVariableName" that takes an array of characters terminating by NULL character (C-string). It will go through the array and return whether it is an acceptable variable name or not. It is acceptable if - it does not start with a digit - it only contains alphabet (uppercase or lowercase) or digit In addition, it also returns the number of uppercase and lowercase in that C-string.

For example, if the array is {'H', 'e', 'l', 'l', 'o', '\0'}, it will return true (valid), 1 (uppercase), 4 (lowercase) If the array is {'H', 'e', ' ', 'l', '\0'}, it will return false (invalid), 1 (uppercase), 2 (lowercase) If the array is {'\0'}, it returns false (invalid), 0 (uppercase) and 0 (lowercase). If the array is {'1', 'H', '\0'}, it returns false (invalid), 1 (uppercase) and 0 (lowercase). If the array is {'H', '1', '\0'}, it returns true (valid), 1 (uppercase) and 0 (lowercase). If the array is {'h', '1', '\0'}, it returns true (valid), 0 (uppercase) and 1 (lowercase).

Note: please do not pass in the size of the array as this is a C-string.

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!