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 Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)
- In C, use the starter code pleasearrow_forwardComputer Science R programming Adjust your functions to take into account upper and lower case letters, as well as spaces. Bonus: can your functions also deal with special characters. Apply your first function to the variable x1 and then the second function to your output, so you can convert it back. x1 <- "Hello My Friend" x2 <- "This: Is, Comma: Horror!"arrow_forwardWhat is the purpose of the boolean data type? (C++) - One can manipulate logical expressions using the boolean data type. - Boolean data type is declared as a variable initially. - Boolean data type must include decimal spaces and evaluate mathematically to 0 or 1. - One can manipulate algebraic expressions using the boolean data type.arrow_forward
- Please code using C++ and only use header <iostream>. Any others will not be accepted. Please write using a globlal constant const int NO=10 and not #define. Thak you!arrow_forwardin c++. Paste working code using the outline above please.arrow_forwardRequired in c++ (do not use arrays or complicated code please)arrow_forward
- True or False C# allows you to access the individual characters in a string using subscript notationarrow_forwardYou have to write code c++arrow_forwardC programming. Use functions. Code the function named "deci" that printes the largest and smallest of the 3 decimal values sent into it.arrow_forward
- Hi I need help please I need to make a function that converts an infix expression to a post fix expression such as converting a + b * (c-d) To a b c d - * +arrow_forwardIn C++ Declare a variable named Holiday and initialize it to "New Year". Use the appropriate data typearrow_forward2. What data type would you use to allow a function to receive an Int or nil value as its parameter? func display(num: ____ ) { if num == nil { print("Not a number") } else { print(num) } } display(num: 5) display(num: nil)arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr