Remove consecutive alphabets which are in same case | C ++ program to remove the consecutive characters from a string that are in same case ; Function to return the modified string ; Traverse through the remaining characters in the string ; If the current and the previous characters are not in the same case then take the character ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; string removeChars ( string s ) { string modifiedStr = " " ; modifiedStr += s [ 0 ] ; for ( int i = 1 ; i < s . length ( ) ; i ++ ) { if ( isupper ( s [ i ] ) && islower ( s [ i - 1 ] ) || islower ( s [ i ] ) && isupper ( s [ i - 1 ] ) ) modifiedStr += s [ i ] ; } return modifiedStr ; } int main ( ) { string s = " GeeksForGeeks " ; cout << removeChars ( s ) ; return 0 ; }