✨The entirety of these are generated by chatGPT, including descriptions around building and running them 🚀🤖✨
How awesome this is!!😎
Read on..
1. Java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
To run this program, save it in a file named HelloWorld.java
and compile it using the javac
command:
javac HelloWorld.java
This will print "Hello, World!" to the console.
2. JavaScript
console.log("Hello, World!");
To run this program, save it in a file with a .js
extension, such as hello-world.js
, and run it using a JavaScript interpreter, such as Node.js:
node hello-world.js
This will print "Hello, World!" to the console.
3. Python
Here is a hello-world program in Python:
print("Hello, World!")
To run this program, save it in a file with a .py
extension, such as hello-world.py
, and run it using a Python interpreter:
python hello-world.py
This will print "Hello, World!" to the console.
4. Golang
Here is a hello-world program in Go:
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
To run this program, save it in a file named hello-world.go
and compile it using the go build
command:
go build hello-world.go
This will create an executable file named hello-world
in the same directory. Run this file to see the output:
./hello-world
This will print "Hello, World!" to the console.
5. Rust
Here is a hello-world program in Rust:
fn main() {
println!("Hello, World!");
}
To run this program, save it in a file named hello-world.rs
and compile it using the rustc
command:
rustc hello-world.rs
This will create an executable file named hello-world
in the same directory. Run this file to see the output:
./hello-world
This will print "Hello, World!" to the console.
6. C
Here is a hello-world program in C:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
To run this program, save it in a file named hello-world.c
and compile it using the gcc
command:
gcc hello-world.c -o hello-world
This will create an executable file named hello-world
in the same directory. Run this file to see the output:
./hello-world
This will print "Hello, World!" to the console.
7. C++
Here is a hello-world program in C++:
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
To run this program, save it in a file named hello-world.cpp
and compile it using the g++
command:
g++ hello-world.cpp -o hello-world
This will create an executable file named hello-world
in the same directory. Run this file to see the output:
./hello-world
This will print "Hello, World!" to the console.
8. Ruby
Here is a hello-world program in Ruby:
puts "Hello, World!"
To run this program, save it in a file with a .rb
extension, such as hello-world.rb
, and run it using a Ruby interpreter:
ruby hello-world.rb
This will print "Hello, World!" to the console.
9. Clojure
Here is a hello-world program in Clojure:
(println "Hello, World!")
To run this program, save it in a file with a .clj
extension, such as hello-world.clj
, and run it using the clojure
command:
clojure hello-world.clj
This will print "Hello, World!" to the console.
10. Elixir
Here is a hello-world program in Elixir:
IO.puts "Hello, World!"
To run this program, save it in a file with a .exs
extension, such as hello-world.exs
, and run it using the elixir
command:
elixir hello-world.exs
This will print "Hello, World!" to the console.
11. C-sharp
Here is a hello-world program in C#:
using System;
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
}
}
}
To run this program, save it in a file named HelloWorld.cs
and compile it using the csc
command:
csc HelloWorld.cs
This will create an executable file named HelloWorld.exe
in the same directory. Run this file to see the output:
HelloWorld.exe
This will print "Hello, World!" to the console.
12. PHP
Here is a hello-world program in PHP:
<?php
echo "Hello, World!";
To run this program, save it in a file with a .php
extension, such as hello-world.php
, and run it using the php
command:
php hello-world.php
This will print "Hello, World!" to the console.
13. Perl
Here is a hello-world program in Perl:
use strict;
use warnings;
print "Hello, World!\n";
To run this program, save it in a file with a .pl
extension, such as hello-world.pl
, and run it using the perl
command:
perl hello-world.pl
This will print "Hello, World!" to the console.
14. Swift
Here is a hello-world program in Swift:
print("Hello, World!")
To run this program, save it in a file with a .swift
extension, such as hello-world.swift
, and run it using the swift
command:
swift hello-world.swift
This will print "Hello, World!" to the console.
15. Objective-C
Here is a hello-world program in Objective-C:
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
NSLog(@"Hello, World!");
}
return 0;
}
To run this program, save it in a file named hello-world.m
and compile it using the clang
command:
clang -fobjc-arc hello-world.m -o hello-world
This will create an executable file named hello-world
in the same directory. Run this file to see the output:
./hello-world
This will print "Hello, World!" to the console.
16. Kotlin
Here is a hello-world program in Kotlin:
fun main() {
println("Hello, World!")
}
To run this program, save it in a file with a .kt
extension, such as hello-world.kt
, and compile it using the kotlinc
command:
kotlinc hello-world.kt -include-runtime -d hello-world.jar
This will create a JAR file named hello-world.jar
in the same directory. Run this file to see the output:
java -jar hello-world.jar
This will print "Hello, World!" to the console.
17. Scala
Here is a hello-world program in Scala:
object HelloWorld {
def main(args: Array[String]): Unit = {
println("Hello, World!")
}
}
To run this program, save it in a file with a .scala
extension, such as hello-world.scala
, and compile it using the scalac
command:
scalac hello-world.scala
This will create a class file named HelloWorld.class
in the same directory. Run this file using the scala
command:
scala HelloWorld
This will print "Hello, World!" to the console.
Top comments (0)