Programming is a highly sought-after skill in today’s digital world. Whether you’re looking to start a new career or simply expand your existing skillset, learning to code is an excellent way to open up new opportunities. One of the simplest, yet most impactful, programs you can write as a beginner is “Hello World”. This program serves as an introduction to the basic syntax and structure of a programming language.
In this comprehensive guide, we will show you how to print “Hello World” in 20 of the most popular programming languages. This will provide you with a foundational understanding of how different programming languages approach the task of printing a simple message on the screen. So, get ready to dive into the world of coding and let’s get started!
Printing `Hello World`
in 20 Programming Languages
- Python
Python uses the print()
method to print a string on the console. The string must in enclosed under double quotes.
1 | print("Hello World") |
Java uses the println() method is used to print content on the output console.
1 2 3 4 5 | public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World"); } } |
In the C programming language, printf() function is used to print values on the output console.
1 2 3 4 5 6 | #include<stdio.h> int main() { printf("Hello World"); return 0; } |
1 2 3 4 5 6 | #include<iostream> int main() { std::cout << "Hello World" << std::endl; return 0; } |
1 | puts "Hello World" |
1 2 3 | <?php echo "Hello World"; ?> |
1 | console.log("Hello World"); |
1 | print("Hello World") |
1 2 3 4 5 6 7 | package main import "fmt" func main() { fmt.Println("Hello World") } |
1 2 3 | fun main(args: Array<String>) { println("Hello World") } |
1 | cat("Hello World") |
1 | print "Hello World\n"; |
1 2 3 4 5 | object HelloWorld { def main(args: Array[String]) { println("Hello World") } } |
1 2 3 4 5 6 7 8 | #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSLog (@"Hello World"); [pool drain]; return 0; } |
1 | echo "Hello World" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | section .data msg db 'Hello World',0 section .text global _start _start: ; write(1, msg, 12) mov eax, 4 mov ebx, 1 mov ecx, msg mov edx, 12 int 0x80 ; exit(0) mov eax, 1 xor ebx, ebx int 0x80 |
1 | SELECT 'Hello World'; |
1 2 3 | fn main() { println!("Hello World"); } |
1 | console.log("Hello World"); |
1 | print("Hello World") |
Conclusion
In conclusion, “Hello World” is a simple yet powerful program that helps beginners understand the basic syntax and structure of a new programming language. By printing “Hello World” in 20 popular programming languages, we hope to provide a comprehensive guide to help those new to the program understand how the syntax and structure of a program can vary between languages. Whether you are just starting out or looking to expand your skills, this guide serves as a valuable resource to help you get started. Regardless of the language you choose, the most important aspect is to keep practicing and building on your skills. Happy coding!