C++ Exercises: Replace all the lower-case letters of a given string with the corresponding capital letters
C++ Basic: Exercise-70 with Solution
Write a C++ program to replace all the lower-case letters in a given string with the corresponding capital letters.
Visual Presentation:
Sample Solution:
C++ Code :
#include <iostream> // Including input-output stream header file
#include <algorithm> // Including algorithm header for transform function
using namespace std; // Using the standard namespace
int main() {
string text; // Declaring a string variable named 'text' to store user input
getline(cin, text); // Getting a line of text input from the user
// Using transform function to convert each character of the string to uppercase
transform(text.begin(), text.end(), text.begin(), ::toupper);
// Displaying the converted string in uppercase
cout << text << endl;
return 0; // Indicating successful completion of the program
}
Sample Output:
Sample Input the quick brown fox jumps over the lazy dog. sample Output THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
Flowchart:
C++ Code Editor:
Previous: Write a C++ program to read an integer n and prints the factorial of n, assume that n ≤ 10.
Next: Write a C++ program which reads a sequence of integers and prints mode values of the sequence. The number of integers is greater than or equals to 1 and less than or equals to 100.
What is the difficulty level of this exercise?
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/cpp-exercises/basic/cpp-basic-exercise-70.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics