Question
C++ General requirements: - No global variables - No multiple return statements in one function - Show how you have tested these functions - cin
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: 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
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