
Concept explainers
Read a 2-character string from input into variable inputString. Declare a Boolean variable isValid and assign isValid with true if inputString contains a lowercase letter. Otherwise, assign isValid with false.
Ex: If the input is y-, then isValid is assigned with true, so the output is:
Valid string
Ex: If the input is 21, then isValid is assigned with false, so the output is:
Invalid string
Note: Use getline(cin, inputString) to read the entire line from input into inputString.
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string inputString;
/* Your code goes here */
if (isValid) {
cout << "Valid string" << endl;
}
else {
cout << "Invalid string" << endl;
}
return 0;
}

Trending nowThis is a popular solution!
Step by stepSolved in 5 steps with 4 images

- C++arrow_forwardWhat characters are used as delimiters when null is passed as an argument to the Split method of a string object?arrow_forwardCode_Program to check if strings are rotations of each other or not? Approach Create a temp string and store concatenation of str1 to str1 in temp. temp = str1.str1 If str2 is a substring of temp then str1 and str2 are rotations of each other. Example:str1 = "ABACD" str2 = "CDABA".arrow_forward
- Code_Program to check if strings are rotations of each other or not? Approach Create a temp string and store concatenation of str1 to str1 in temp. temp = str1.str1 If str2 is a substring of temp then str1 and str2 are rotations of each other. Example:str1 = "ABACD" str2 = "CDABA".arrow_forwardJava Programming:- Prompt the user to enter a string and then check if the string contains two consecutive characters which are same. Sample Input: “abccde” Output: “Yes” Sample Input: “abcde” Output: “No”arrow_forwardAccessing a single character out of a string is called:a) slicing b) concatenation c) assignment d) indexingarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





