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 of a given string with the corresponding capital letters.
Pictorial Presentation:
Sample Solution:
C++ Code :
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
string text;
getline(cin, text);
transform(text.begin(), text.end(), text.begin(), ::toupper);
cout << text << endl;
return 0;
}
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:
Contribute your code and comments through Disqus.
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?