Print “Hello world”

Contents

Output

Hello Wolrd

Code examples


C

hello_world.c

/* 
 * cc -o hello_world hello_world.c;./hello_world;rm hello_world;
 */
#include<stdio.h>
int main() {
    printf("Hello World\n");
}

C++

hello_world.cpp

/*
 * g++ -o hello_world hello_world.cpp;./hello_world;rm hello_world;   
 */
#include <iostream>
using namespace std;
int main() {
     std::cout << "Hello World" << endl;
}

C#

hello_world.cs

/*
* mcs hello_world.cs;mono hello_world.exe;rm hello_world.exe;
*/
using System;
public class HelloWorld {
    public void helloWorld() {
        Console.WriteLine("Hello World");
    }
    public static void Main()  {
         HelloWorld hw = new HelloWorld();
         hw.helloWorld();
    }
}

Go

hello_world.go

// go build hello_world.go
package main
import "fmt"
func main() {
    fmt.Println("Hello World")
}

Java

HelloWorld.java

/*
javac HelloWorld.java;java HelloWorld;rm HelloWorld.class;
*/
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
}

JavaScript

console.log("Hello World");

Perl

print "Hello World";

PHP

print "Hello World";

Python

print("Hello World")

Ruby

print("Hello World")

Rust

/* 
 * rustc hello_wold.rs
 */
fn main() {
    println!("Hello World");
}

Shell

echo "Hello World";