Fundamentals 2 min read

How to Say “Happy New Year” in 20 Programming Languages

This article showcases simple code snippets that print a New Year greeting in twenty different programming languages, illustrating basic output syntax across Java, C, C++, Python, C#, PHP, JavaScript, Go, Swift, Ruby, VB, Perl, HTML, Scala, AWK, Pascal, and Prolog.

21CTO
21CTO
21CTO
How to Say “Happy New Year” in 20 Programming Languages

Java

System.out.println("祝大家新年快乐!");

C

printf("祝大家新年快乐!");

C++

std::cout << "祝大家新年快乐" << std::endl;

Python

print("祝大家新年快乐!")

C#

Console.WriteLine("祝大家新年快乐!");

PHP

echo "祝大家新年快乐!";

JavaScript

document.write("祝大家新年快乐!");

Go

fmt.print("祝大家新年快乐!");

Swift

print("祝大家新年快乐!")

Ruby

puts "祝大家新年快乐!"

VB

MsgBox("祝大家新年快乐!")

Perl

print "祝大家新年快乐!";

HTML

<p>祝大家新年快乐!</p>

Scala

println("祝大家新年快乐!");

AWK

echo | awk '{print "祝大家新年快乐!"}'

Pascal

writeln('祝大家新年快乐!')

Prolog

write("祝大家新年快乐!").
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

code snippetssyntaxnew yearmultiple languages
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.