text: Check if lowercase and uppercase characters are in same order | C ++ program to check if lowercase and uppercase characters are in same order ; Function to check if both the case follow the same order ; Traverse the string ; Store both lowercase and uppercase in two different strings ; using transform ( ) function and :: toupper in STL ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; bool isCheck ( string str ) { int len = str . length ( ) ; string lowerStr = " " , upperStr = " " ; for ( int i = 0 ; i < len ; i ++ ) { if ( str [ i ] >= 65 && str [ i ] <= 91 ) upperStr = upperStr + str [ i ] ; else lowerStr = lowerStr + str [ i ] ; } transform ( lowerStr . begin ( ) , lowerStr . end ( ) , lowerStr . begin ( ) , :: toupper ) ; return lowerStr == upperStr ; } int main ( ) { string str = " geeGkEEsKS " ; isCheck ( str ) ? cout << " Yes " : cout << " No " ; return 0 ; }