1Saying Hello

The “Hello, World” program is the first program you learn to write in many languages, but it doesn’t involve any input.

So create a program that prompts for your name and prints a greeting using your name.

Example Output

 
What is your name? Brian
 
Hello, Brian, nice to meet you!

Constraint

  • Keep the input, string concatenation, and output separate.

Challenges

  • Write a new version of the program without using any variables.

  • Write a version of the program that displays different greetings for different people. This would be a good challenge to try after you’ve completed the exercises in Chapter 4, Making Decisions and Chapter 7, Data Structures.

Get Exercises for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.