Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

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:

C++ Exercises: Replace all the lower-case letters of a given string with the corresponding capital letters

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:

Flowchart: Replace all the lower-case letters of a given string with the corresponding capital letters

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?