Conversion of whole String to uppercase or lowercase using STL in C++ Last Updated : 10 Jan, 2023 Comments Improve Suggest changes Like Article Like Report Try it on GfG Practice Given a string, convert the whole string to uppercase or lowercase using STL in C++. Examples: For uppercase conversionInput: s = "String"Output: s = "STRING" For lowercase conversionInput: s = "String"Output: s = "string" Functions used : transform : Performs a transformation on given array/string. toupper(char c): Returns the upper case version of character c. If c is already in uppercase, return c itself. tolower(char c) : Returns lower case version of character c. If c is already in lowercase, return c itself. CPP // C++ program to convert whole string to // uppercase or lowercase using STL. #include<bits/stdc++.h> using namespace std; int main(){ // s1 is the string which is converted to uppercase string s1 = "abcde"; // using transform() function and ::toupper in STL transform(s1.begin(), s1.end(), s1.begin(), ::toupper); cout<<s1<<endl; // s2 is the string which is converted to lowercase string s2 = "WXYZ"; // using transform() function and ::tolower in STL transform(s2.begin(), s2.end(), s2.begin(), ::tolower); cout<<s2<<endl; return 0; } OutputABCDE wxyz Time complexity: O(N) where N is length of string ,as to transform string to Upper/Lower we have to traverse through all letter of string once.Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article Conversion of whole String to uppercase or lowercase using STL in C++ J Jatin Goyal Improve Article Tags : Strings Computer Science Fundamentals DSA STL cpp-string C++ Basic Programs C++ String Programs +3 More Practice Tags : STLStrings Similar Reads Case conversion (Lower to Upper and Vice Versa) of a string using BitWise operators in C/C++ Given a string, write a function that converts it either from lower to upper case or from upper to lower case using the bitwise operators &(AND), |(OR), ~(NOT) in place and returns the string. Many of us know that Bitwise manipulations are faster than performing arithmetic operations for a compi 5 min read How to create half of the string in uppercase and the other half in lowercase? The first thing that we have to keep in my mind while solving this kind of problem is that the strings are immutable i.e, If I am taking the following string var string1 = "geeksforgeeks";string1[0] = "G";console.log(string1);As strings are immutable, so we cannot change the character of the string, 9 min read Check string for all uppercase-lowercase or first uppercase and rest lowercase characters Given a string S, the task is to check if all the characters in S are in lowercase, or all the characters are in uppercase or only the first character is in uppercase, and the remaining characters are in lowercase. Print "YES" if any of the condition gets satisfied else print "NO". Examples: Input: 6 min read Convert all lowercase characters to uppercase whose ASCII value is co-prime with k Given an integer 'k' and a string 'str' consisting of characters from English alphabets. The task is to convert all lower case character to uppercase whose ASCII value is co-prime with k. Examples: Input: str = "geeksforgeeks", k = 4 Output: GEEKSfOrGEEKS 'f' and 'r' are the only characters whose AS 6 min read Check if uppercase characters (Capital letters) in a string are used correctly or not | Set 2 Given a string S consisting of uppercase and lowercase letters, the task is to check if uppercase characters are used correctly in the given string or not. Correct usage of uppercase characters are as follows: All characters in the string are in uppercase. For example, âGEEKSâ.None of the characters 5 min read Toggle case of a string using Bitwise Operators Given a string, write a function that returns toggle case of a string using the bitwise operators in place.In ASCII codes, character âAâ is integer 65 = (0100 0001)2, while character âaâ is integer 97 = (0110 0001)2. Similarly, character 'D' is integer 68 = (0100 0100)2, while character 'd' is integ 4 min read Minimum length substring with each letter occurring both in uppercase and lowercase Find the minimum length substring in the given string str such that, in the substring, each alphabet appears at least once in lower case and at least once in upper case. Examples: Input: S = âAaBbCcâOutput: AaExplanation: Possible substrings that has each alphabet in lowercase and uppercase are:AaBb 14 min read String containing first letter of every word in a given string with spaces String str is given which contains lowercase English letters and spaces. It may contain multiple spaces. Get the first letter of every word and return the result as a string. The result should not contain any space. Examples: Input : str = "geeks for geeks" Output : gfg Input : str = "geeks for geek 11 min read Check if uppercase characters in a string are used correctly or not Given a string S consisting of uppercase and lowercase letters, the task is to check if uppercase characters are used correctly in the given string or not. Correct usage of uppercase characters are as follows: All characters in the string are in uppercase. For example, "GEEKS".None of the characters 8 min read Number of substrings having an equal number of lowercase and uppercase letters Given string S consists of lowercase and uppercase letters, the task is to find the number of substrings having an equal number of lowercase and uppercase letters. Examples: Input: S = âgEEkâOutput: 3Explanation:The following are the substrings having an equal number of lowercase and uppercase lette 11 min read Like