Write a program that
reads a single name from the standard input device
Hello, <Name>! on the standard output device.
The standard input and output devices
are usually the keyboard and screen of a command line session.
$ ./hi1 John Hello, John! $ ./hi1 Mary Hello, Mary!
Input consists of a single line with a person’s given name without spaces. This name is composed of letters of the English alphabet and contains at most 30 characters.
Output should contain a single line with
This line is proper and should be terminated by a line break.
Submit your solution to be graded according to the following list:
If you do not know where to start, read the Computer Science by Example book. First, setup your environment then learn the programming basics. Here are some hints:
Automated judge: Keep in mind that when your program is submitted it will not be run by a human but instead by an automated judge. Instructions should be followed exactly or the judge will not give you a full score.
Your program should not print messages like
Please type your name:.
Instead, just print the required
Hello, <Name>! message.
Watch out for the correct punctuation and casing
and be sure to include a line break.
Your program should print
Hello, <Name>! then exit immediately.
Do not use
sleep(1) or anything of sorts.
Redirecting input: On most systems (Windows / Linux / OS X), it is possible to redirect the standard input and output of your program to files, like so:
$ ./hi1 <inputfile.txt >outputfile.txt
So, if you create a plain text file with a name, the above command will produce another plain text file with a hello message.
This is actually how the automated judge runs your program.
On Windows, you should not use
./ to run a program in the current directory,
C:\> hi1.exe Joseph Hello, Joseph!
Easier exercises: If you have difficulty with this exercise, try the hello exercise first.
try first: hello
try also: repeat1
try next: age1
Copyright © 2020-2022 Rudy Matela
All rights reserved