HomeInterview QuestionsWrite a program that reads your name as input and …

Write a program that reads your name as input and prints it on the second line of output.

🟢 Easy Coding Fresher level
1Times asked
Aug 2026Last seen
Aug 2026First seen

💡 Model Answer

Read the name from standard input, then output a blank line followed by the name. In Python:

python
name = input().strip()
print()
print(name)

In C++:

cpp
#include <iostream>
int main(){
    std::string name; std::getline(std::cin, name);
    std::cout << "\n" << name << std::endl;
    return 0;
}

The algorithm is O(1) time and O(1) space, as it only stores the input string once.

This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.

🎤 Get questions like this answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500