Transform Characters

Lab C++ Beginner 10 points

Read a line and print it in upper case, then in lower case, by looping over the characters with a range-for loop and a reference.

Input

One line.

Output

Two lines.

Example

Input

Hello, World!

Output

HELLO, WORLD!
hello, world!
Sample input available Sample output available
Editor
C++

Hints

for (char &c : s) gives a reference to each character, so you can change it.

Solution explanation

Without the &, c would be a copy and the string wouldn't change.

Show solution
#include <iostream>
#include <string>
#include <cctype>
using namespace std;

int main() {
    string s;
    getline(cin, s);
    string upper = s, lower = s;
    for (char &c : upper) c = toupper(c);
    for (char &c : lower) c = tolower(c);
    cout << upper << "\n" << lower << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD