Hello World!#1024

Hello World! (Editorial)

Algorithm Analysis

In the task, we need to print the message “Hello World!”.

Algorithm Implementation – printf

We print the message “Hello World!” using the printf function.

#include <stdio.h>

int main(void)
{
    printf("Hello World!\n");
    return 0;
}

Algorithm Implementation – puts

We print the message “Hello World!” using the puts function. The puts function always ends the text output with a newline character (\n).

#include <stdio.h>

int main(void)
{
    puts("Hello World!");
    return 0;
}

Java Implementation

We print the message “Hello World!” using the System.out.println function.

import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        System.out.println("Hello World!");
    }
}

Python Implementation

We print the message “Hello World!” using the print function.

print("Hello World!")

Go Implementation

package main

import "fmt"

func main() {
    fmt.Println("Hello World!");
}

C# Implementation

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleAppCSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            System.Console.WriteLine("Hello World!");
        }
    }
}

Ruby Implementation

puts "Hello World!"

Rust Implementation

fn main() {
    println!("Hello World!");
}

Haskell Implementation

main = putStrLn "hello world"