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)
- C++ PROGRAMMING Create a C++ program that accepts an English sentence and converts it to Pig Latin. The rules of Pig Latin are as follows: If the word starts with a vowel, add the word "yay" in the end. If the word starts with a consonant, move the first letter of the word in the end and add "ay" in the end. If the word starts with a capital letter, follow the rule and convert the first letter of the converted Pig Latin word into a capital letter. (i.e. Hello -> ElloHay) If there are numbers in the sentence, they should not be translated. A word with a combination of letters and numbers will not be tested. Spacing and punctations must be preserved. Sample Input: A quick brown fox jumps over the 100 lazy dogs. Expected Output: Ayay uickqay rownbay oxfay umpsjay overyay hetay 100 azylay ogsday.arrow_forwardCreate a function called reverse() that has a string parameter. The function reverses the characters of the string locally. ( in C language)arrow_forwardWhat header file must you include in a program using string class objects?arrow_forward
- what is character-manipulationfunctions ?arrow_forwardUpper, Dis-upper Code in C languagearrow_forward#include <stdio.h>#include <string.h> #pragma warning(disable : 4996) // compiler directive for Visual Studio only // Read before you start:// You are given a partially complete program. Complete the functions in order for this program to work successfully.// All instructions are given above the required functions, please read them and follow them carefully. // You shoud not modify the function return types or parameters.// You can assume that all inputs are valid. Ex: If prompted for an integer, the user will input an integer.// You can use only the strlen() of strings.h library to check string length. Do not use any other string functions // because you are supposed to use pointers for this homework. // **** DO NOT use arrays to store or to index the characters in the string **** // Global Macro Values. They are used to define the size of 2D array of characters#define NUM_STRINGS 4#define STRING_LENGTH 50 // Forward Declarationsvoid…arrow_forward
- c programming <stdio.h> <string.h> 1 dimentional array strings output: type any word: handsomeNew word: smoenahd type any word: beautifulNew word: ubeiflatuarrow_forwardCODE USING C++ 2. First Even Road by CodeChum Admin I've been newly assigned as the city's road planner but this job seems tougher than I thought! Almost all of the roads in this city are uneven. To fix these, I need to find an even road as a reference. Fortunately, the mayor told me that there's 1 even road somewhere and if I persevere, I could find it. Could you please help me with this? Instructions: Your task is to ask the user for the number of rows and columns of a 2D array. Then, print the row number of the row where the sum of all of its elements is even. For this problem, it is guaranteed that there is one and only one such row. Input 1. Number of rows 2. Number of columns 3. Elements of the 2D array Output Note that the row number starts at 0, not 1. Enter·#·of·rows:·3 Enter·#·of·columns:·3 Enter·elements: 2·7·4 1·1·2 0·5·0 Even·row:·1arrow_forwardCode using c++ 2. First Even Road by CodeChum Admin I've been newly assigned as the city's road planner but this job seems tougher than I thought! Almost all of the roads in this city are uneven. To fix these, I need to find an even road as a reference. Fortunately, the mayor told me that there's 1 even road somewhere and if I persevere, I could find it. Could you please help me with this? Instructions: Your task is to ask the user for the number of rows and columns of a 2D array. Then, print the row number of the row where the sum of all of its elements is even. For this problem, it is guaranteed that there is one and only one such row. Input 1. Number of rows 2. Number of columns 3. Elements of the 2D array Output Enter·#·of·rows:·3 Enter·#·of·columns:·3 Enter·elements: 2·7·4 1·1·2 0·5·0 Even·row:·1arrow_forward
- C++ You are required to write three overloaded functions called stringOperation that take in the following formal parameters list: Function 1: takes as input a string, ONE character, and an integer n, and returns true if the string contains that character EXACTLY an n number of times. Function 2: takes as input a string and TWO alphabatical characters c1 and c2, and returns true if all the string characters fall in the range between the two passed characters (exclusive) (You must make sure to order the characters first if c2 < c1 ). Function 3: takes as input a string and THREE alphabatical characters c1, c2 and c3. The function reorders the characters in asecnding order, such that c1 holds the smallest character and c3 holds the largest character. The function returns true if the string characters that fall between c1 and c2 (exclusive) is less than the string characters that fall between c2 and c3 (exclusive). Do not write and submit the main subroutine, or any include…arrow_forwardWhen invoking a function that takes several arguments, does the order in which the parameters are supplied matter? Computer sciencearrow_forwardC++ printSmaller is a function that accepts two int parameters and returns no value. It will print the value of the smaller one parameters. The function protoype is as follows: void printSmaller(int num1, int num2); write the statments to read two integers and call this function to display the smaller one.arrow_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