String Basics

Lab C++ Beginner 10 points

Read a word. Print its length, first and last characters, and the word with ! appended.

Input

One word.

Output

Four lines.

Example

Input

hello

Output

5
h
o
hello!
Sample input available Sample output available
Editor
C++

Hints

size() gives the length; back() the last character.

+ joins strings.

Solution explanation

std::string manages its own memory and supports +, == and <.

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

int main() {
    string w;
    cin >> w;
    cout << w.size() << "\n" << w[0] << "\n" << w.back() << "\n" << w + "!" << "\n";
    return 0;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD