DEV Community

Cover image for Hello world examples in 10 different languages
Sai gowtham
Sai gowtham

Posted on • Edited on • Originally published at codeexamples.dev

Hello world examples in 10 different languages

In this article, you learn about how to write a hello world program in 10
different programming languages.

1. C

#include <stdio.h>

int main(void)
{
  printf("Hello World\n");
  return 0; // ends the program
}
Enter fullscreen mode Exit fullscreen mode

2. C++

#include <iostream>
using namespace std;
int main()
{
    cout << "Hello, World!"; // std output stream
    return 0; // exit status
}
Enter fullscreen mode Exit fullscreen mode

3. C# (c sharp)

using System;

namespace HelloWorld
{
    class Hello {
        static void Main(string[] args)
        {      // prints hello world
            System.Console.WriteLine("Hello World!");
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

4. Java

class HelloWorld {
    public static void main( String []args ) {
        System.out.println( "Hello World!" );
    }
}
Enter fullscreen mode Exit fullscreen mode

5. Php

<?php
echo "Hello World!";
?>
Enter fullscreen mode Exit fullscreen mode

6. Python

print('Hello ,world');
Enter fullscreen mode Exit fullscreen mode

7. Ruby

puts "Hello World!"
Enter fullscreen mode Exit fullscreen mode

8. Scala

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println("Hello, world!")
  }
}
Enter fullscreen mode Exit fullscreen mode

9. JavaScript

console.log('Hello World');
Enter fullscreen mode Exit fullscreen mode

10. Kotlin

fun main(args: Array<String>) {
    println("Hello World!")
}
Enter fullscreen mode Exit fullscreen mode

How to fix the error “Module was compiled with an incompatible version of Kotlin

I hope you learned something new if your favorite programming language is missing in the above list try to add it in the below comments section.

Top comments (7)

Collapse
 
hnnx profile image
Nejc

DAT 01 48
MOV 00 01
DAT 01 65
MOV 00 01
DAT 01 6C
MOV 00 01
MOV 00 01
DAT 02 6F
MOV 00 02
DAT 01 20
MOV 00 01
DAT 01 77
MOV 00 01
MOV 00 02
DAT 01 72
MOV 00 01
DAT 01 6C
MOV 00 01
DAT 01 64
MOV 00 01

Collapse
 
fennecdjay profile image
Jérémie Astor

It looks like some kind of assembly to me, but would you mind specifying which language it is?

Collapse
 
nciphalucas profile image
Vuyisile Lucas Ncipha • Edited

For C# you have already declare the namespace System so it will be just

Console.WriteLine("Hello World")
Collapse
 
fennecdjay profile image
Jérémie Astor
<<< "Hello World" >>>;

in Gwion.

Collapse
 
juancarlospaco profile image
Juan Carlos
echo "Hello World"

Nim

Collapse
 
calyce8 profile image
Calyce
Collapse
 
gabrielaraujocomp profile image
Gabriel Araújo

wow