Question: bool valid _ identifier ( const strings str ) ; identifier contains only letters, digits, and underscores and may not start with a digit. For
bool valididentifierconst strings str; identifier contains only letters, digits, and underscores and may not start with a digit.
For example, the following function calls shall return true:
valididentifierabcblValididentifierabCD
valididentifier valididentifier a
valididentifier valididentifierC
The following function calls shall return false:
valid identifier valid identifierab CD
valididentifier valididentifiera$
Hint: Declare a bool variable and set it to true. Then set up a loop to iterate through the characters and break out of the loop when an invalid character is present.
The following illustrates a sample output of incomplete testing. The first column shows the identifiers being tested and the second column shows the result of the valid identifier function.
IDENTIFIERVALID OR NOT
tabletrueabcottrueabcdfalsetrue
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
