Concept explainers
Explanation of Solution
“cctype” header file:
The “cctype” header file is used to declare a set of function to categorize the individual characters in C++. The functions in that header file test a single character argument and return either true or false.
The “isalpha” and “isdigit” functions must need “cctype” header file for testing the character argument.
isalpha – check the given letter is alphabet or not
isdigit – check the given letter is digit or not.
isalpha:
If the argument is the letter either uppercase or lowercase, it return true otherwise it return false.
Example:
Consider the example of “isalpha” is as follows:
//declare and initialize the value to the variable
char c = 'a';
//check the condition
if (isalpha (c))
{
//display the output
cout << "This is a letter";
}
Here, the “c” variable holds the value of “a”. The above “if” condition is used to check if the variable “c” is an alphabet by using “isalpha” character function.
isdigit:
If the argument is a digit, it return true otherwise it return false.
Example:
Consider the example of “isdigit” is as follows:
//declare and initialize the value to the variable
char c = '0';
//check the condition
if ( isdigit (c))
{
//display the output
cout << "This is a digit";
}
Here, the “c” variable holds the value of “0”. The above “if” condition is used to check if the variable “c” is a digit by using “isdigit” character function.
Therefore, the “cctype” header file is used to test a single character argument for “isalpha” and “isdigit” function.
Want to see more full solutions like this?
Chapter 10 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
- What are different inbuilt string functions?arrow_forwardLISP Function help please LISP Programming only A function that generates a random day of the week, then displays a message saying that "Today is ... and tomorrow will be ...". Then use the built-in function random first to generate a number between 0 and 6 (including). The expression (random) by itself generates a random integer. You can call it with one parameter to return a value within the range from 0 to the value of the parameter-1. For example, (random 10) will return a value between 0 and 9. Next, use the number generated at the previous step to retrieve the symbol for the day of the week from the list. Use the built-in elt. Extract the symbol-name of the day first, then apply the built-in function capitalize to it. Use the result in the princ function call, and do the same thing for the next day. Make the function return true (t) instead of the last thing it evaluates, to avoid seeing the message printed more than once.arrow_forwardCreate a C++ Codearrow_forward
- C++ Program using functionsarrow_forwardA header of a C-language function is: void recurs(int current_level, int max_level ) The keyword "void" here signifiesarrow_forwardC++ code please Suppose that the enum flowerType is defined Write a C++ function that can be used to input value in a variable of type flowerType.arrow_forward
- Usernames An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below: Username MUST contain at least 6 characters; Username cannot start with a number; Username can only contain letters or numbers. If valid, the username may be resgistered if it doesn't already exist in the system. You should not use built-in functions to determine the character type such as isnumeric() or islower(). Use the strings given alphabet and numeric to determine if each character is valid. Use the list registered to help you determine if the username is already registered. Don't forget to execute the cell below to use these strings # run this cell to create these variablesalphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'numeric = "0123456789"registered = ["john87", "topmage", "light4ever", "username2"] Write a function nameValidation which receives a String argument name. This function: has name String…arrow_forwardUsernames An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below: Username MUST contain at least 6 characters; Username cannot start with a number; Username can only contain letters or numbers. If valid, the username may be resgistered if it doesn't already exist in the system. You should not use built-in functions to determine the character type such as isnumeric() or islower(). Use the strings given alphabet and numeric to determine if each character is valid. Use the list registered to help you determine if the username is already registered. Don't forget to execute the cell below to use these strings # run this cell to create these variablesalphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'numeric = "0123456789"registered = ["john87", "topmage", "light4ever", "username2"]arrow_forwardUsernames An online company needs your help to implement a program that verifies the username chosen by a new user. Their rules is described below: Username MUST contain at least 6 characters; Username cannot start with a number; Username can only contain letters or numbers. If valid, the username may be resgistered if it doesn't already exist in the system. You should not use built-in functions to determine the character type such as isnumeric() or islower(). Use the strings given alphabet and numeric to determine if each character is valid. Use the list registered to help you determine if the username is already registered. Don't forget to execute the cell below to use these strings # run this cell to create these variablesalphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'numeric = "0123456789"registered = ["john87", "topmage", "light4ever", "username2"] Write a function registerName which receives a String username and it returns a string message. This…arrow_forward
- Code using c++ 2. Solving a Person's Loneliness by CodeChum Admin It's been 1,245 years and our sole Person is getting lonelier each day. This Person definitely needs a partner! Thus, we need to update our Person's design to have a gender as well and there shall be male and female! Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. Your task is to first update the struct Person so that it can have a gender as well. For this program, we shall represent a gender with a single character: 'M' for male and 'F' for female. Then, create a Person, take in an integer user input and a character user input, and then set them as the Person's age and gender respectively. Finally, call the displayPerson() function and pass that Person you created. Input 1. The age of the Person 2.…arrow_forwardC++ Languagearrow_forwardC program it is given that an integer is considered a special integer if the digit cannot be rearranged in a way to produce an integer larger than *431 is a special integer as no other combination of digit would produce and integer that is larger than 431 *312 is not a special in teacher as you could manage the digits as 321 which would be larger than three 12 *any single digit integers such as 5 is always a special integerarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr