Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read
Challenges

"Hello, {name}!"

+3
−1

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.

Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Output rules (2 comments)
A note about self answers (2 comments)

16 answers

+4
−0

jq, 14 bytes

"Hello, \(.)!"

Try it online!

jq has expression interpolation, pretty epic!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+3
−0

Bash, 20 18 bytes

Saved two bytes by removing the quotes; the code works well without them.

echo Hello, `cat`!

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+2
−0

Haskell, 43 35 bytes

main=interact$("Hello, "++).(++"!")

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+2
−0

C (gcc), 43 bytes

a[99];main(){printf("Hello, %s!",gets(a));}

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

2 comment threads

gets is removed from the C standard (2 comments)
a[] (2 comments)
+1
−0

shortC, 30 bytes

B){Cs[100];Qs);R"Hello, %s!",s

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Lua, 35 32 bytes

print("Hello, "..io.read().."!")

Try it online!

Golfed 3 bytes thanks to @Moshi's advice.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Inline (1 comment)
+1
−0

Ruby, 24 21 18 bytes

p"Hello, #{gets}!"

Try it online!

Golfed down 3 bytes thanks to @snail_'s advice. Golfed down 3 bytes thanks to @south's advice.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

21 bytes (2 comments)
+1
−0

AWK, 21 bytes

{print"Hello, "$0"!"}

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

JavaScript, 28 bytes

alert(`Hello, ${prompt()}!`)

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Sclipting, (UTF-16) 14 bytes

낆녬닆묬글⑴긐
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Python 3, 27 bytes

print(f"Hello, {input()}!")

Try it online!

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+1
−0

Japt, 10 bytes

`HÁM, {U}!

Try it

The backtick decompresses a compressed string, the {} is Japt's string interpolation and U is the first input variable.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+0
−0

Factor, 30 29 bytes

[ readln "Hello, %s!"printf ]

Try it online!

Uses io and formatting.

Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+0
−0

PHP, 55 27 21 bytes

Hello, <?=$argv[1]?>!

Try it online!

Golfed 28 bytes thanks to my Software CD post. Golfed 6 bytes thanks to @Shaggy's advice.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

21 bytes (1 comment)
+0
−0

J, 29 char

('!',~'Hello, ',1!:1<1)1!:2<4

Sample run

    ('!',~'Hello, ',1!:1<1)1!:2<4
torres
Hello, torres!
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

+0
−0

Java (JDK), 134 123 118 bytes

interface M{static void main(String[]a){System.out.print("Hello, "+new java.util.Scanner(System.in).nextLine()+"!");}}

Try it online!

Golfed 5 bytes thanks to @user's advice.

Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Did you even try golfing this? The two variable assignments look entirely useless to me. (3 comments)

Sign up to answer this question »

This community is part of the Codidact network. We have other communities too — take a look!

You can also join us in chat!

Want to advertise this community? Use our templates!

Like what we're doing? Support us! Donate