"Hello, {name}!"
Background
While we do have a "Hello, World!" challenge, we still don't have one regarding input. So let's do one!
Challenge
Create a program that takes an input (not as a function argument) then outputs Hello,
, the variable and !
altogether. Standard I/O only applies. Shortest submission per language wins!
Bonus: Use your username as the input.
[jq], 14 bytes "Hello, …
3y ago
Japt, 10 bytes `HÁM, {U …
3y ago
[Bash], 20 18 bytes Saved t …
3y ago
JavaScript, 28 bytes …
3y ago
[C (gcc)], 43 bytes …
3y ago
[Haskell], 43 35 bytes …
3y ago
J, 29 char ``` ('!','Hello, …
3y ago
[AWK], 21 bytes {print" …
3y ago
[shortC], 30 bytes B){C …
3y ago
[Ruby], 24 21 18 bytes …
3y ago
[Sclipting], (UTF-16) 14 bytes …
3y ago
[Lua], 35 32 bytes …
3y ago
[Python 3], 27 bytes …
3y ago
Lean 4, 39 bytes ```lean d …
11d ago
[Factor], 30 29 bytes [ …
2y ago
[PHP], 55 27 21 bytes …
3y ago
[Java (JDK)], 134 123 118 byte …
3y ago
17 answers
You are accessing this answer with a direct link, so it's being shown above all other answers regardless of its score. You can return to the normal view.
Bash, 20 18 bytes
Saved two bytes by removing the quotes; the code works well without them.
echo Hello, `cat`!
0 comment threads
J, 29 char
('!',~'Hello, ',1!:1<1)1!:2<4
Sample run
('!',~'Hello, ',1!:1<1)1!:2<4
torres
Hello, torres!
0 comment threads
Java (JDK), 134 123 118 bytes
interface M{static void main(String[]a){System.out.print("Hello, "+new java.util.Scanner(System.in).nextLine()+"!");}}
Golfed 5 bytes thanks to @user's advice.
1 comment thread
Lean 4, 39 bytes
def x(i:String):String:=s!"Hello, {i}!"
Try it online! (Note that TIO only supports Lean 3, so I sadly am unable to use a link from there.)
0 comment threads
PHP, 55 27 21 bytes
Hello, <?=$argv[1]?>!
Golfed 28 bytes thanks to my Software CD post. Golfed 6 bytes thanks to @Shaggy's advice.
2 comment threads