📜  Hello World程序:学习编程时的第一个程序

📅  最后修改于: 2021-05-29 14:48:15             🧑  作者: Mango

本文向我们介绍了如何使用多种语言编写“ Hello World”的第一个计算机程序。与程序一起提供注释以更好地理解程序中使用的术语和关键字
学习任何编程都可以简化为:

  • 在文本编辑器编写程序,并用正确的扩展名保存它(Java等)
  • 使用编译器或在线IDE编译程序
  • 了解基本术语。

“ Hello World”程序是学习任何编程语言的第一步,也是您将要学习的最简单的程序之一。您所要做的就是在屏幕上显示消息“ Hello World”。现在让我们以大多数语言查看程序:
这是使用不同语言的所有“ Hello World”程序的链接:

1. C语言中的Hello World

C
// Simple C program to
// display "Hello World"
 
// Header file for
// input output functions
#include 
 
// main function -
// where the execution of
// program begins
int main()
{
 
    // prints hello world
    printf("Hello World");
 
    return 0;
}


C++
// Simple C++ program to
// display "Hello World"
 
// Header file for
// input output functions
#include 
 
using namespace std;
 
// main function -
// where the execution of
// program begins
int main()
{
    // prints hello world
    cout << "Hello World";
 
    return 0;
}


C#
// C# program to print Hello World!
 
using System;
 
// namespace declaration
namespace HelloWorldApp {
 
// Class declaration
class Geeks {
 
    // Main Method
    static void Main(string[] args)
    {
 
        // statement
        // printing Hello World!
        Console.WriteLine("Hello World");
 
        // To prevents the screen from
        // running and closing quickly
        Console.ReadKey();
    }
}
}


Java
// This is a simple Java program.
// FileName : "HelloWorld.java"
 
class HelloWorld {
 
    // Your program begins
    // with a call to main().
    // Prints "Hello, World"
    // to the terminal window.
    public static void main(
        String args[])
    {
        System.out.println("Hello World");
    }
}


Python
# Python code for "Hello World"
 
print("Hello World")


Perl
#!/usr/bin/perl
 
# Modules used
use strict;
use warnings;
 
# Print function
print("Hello World\n");
 
# To run the code refer:
# http://bit.ly/2qLYVTG


Scala
// Scala program to print Hello World!
 
object Geeks
{
 
    // Main Method
    def main(args: Array[String])
    {
 
        // prints Hello World
        println("Hello World")
    }
}


Go
// Go program to print Hello World!
 
package main
 
    import "fmt"
 
    // Main function
    func
    main()
{
 
    // prints Hello World
    fmt.Println("!... Hello World ...!")
}


PHP



 

 


HTML

Hello World


JavaScript


Julia
// Julia program
println("Hello World")


R
# Code
cat('Hello World')


Ruby
# code
puts "Hello World"


Solidity
pragma solidity ^0.5.0;
 
contract helloGeeks {
 function renderHelloGeeks () public pure returns (string) {
   return 'Hello World';
 }
}


XML


  Hello World


ObjectiveC
#import
#import
  
int main(void)
{
    NSLog(@"Hello World
");
    return 0;
}


Kotlin
fun main(args: Array) {
    println("Hello World")
}


Dart
void main() {
  print('Hello World');
}


C
// Simple C program to
// display "Hello World"
 
// Header file for
// input output functions
#include 
 
// main function -
// where the execution of
// program begins
int main()
{
 
    // prints hello world
    printf("Hello World");
 
    return 0;
}


C++
// Simple C++ program to
// display "Hello World"
 
// Header file for
// input output functions
#include 
 
using namespace std;
 
// main function -
// where the execution of
// program begins
int main()
{
    // prints hello world
    cout << "Hello World";
 
    return 0;
}


C#
// C# program to print Hello World!
 
using System;
 
// namespace declaration
namespace HelloWorldApp {
 
// Class declaration
class Geeks {
 
    // Main Method
    static void Main(string[] args)
    {
 
        // statement
        // printing Hello World!
        Console.WriteLine("Hello World");
 
        // To prevents the screen from
        // running and closing quickly
        Console.ReadKey();
    }
}
}


Java
// This is a simple Java program.
// FileName : "HelloWorld.java"
 
class HelloWorld {
 
    // Your program begins
    // with a call to main().
    // Prints "Hello, World"
    // to the terminal window.
    public static void main(
        String args[])
    {
        System.out.println("Hello World");
    }
}


Python
# Python code for "Hello World"
 
print("Hello World")


Perl
#!/usr/bin/perl
 
# Modules used
use strict;
use warnings;
 
# Print function
print("Hello World\n");
 
# To run the code refer:
# http://bit.ly/2qLYVTG


Scala
// Scala program to print Hello World!
 
object Geeks
{
 
    // Main Method
    def main(args: Array[String])
    {
 
        // prints Hello World
        println("Hello World")
    }
}


HTML

Hello World


PHP



 

 


Julia
println("Hello World")


Ruby
puts "Hello World"


R
cat('Hello World')


Go
package main
   
import "fmt"
   
// Main function
func main() {
   
    fmt.Println("Hello World")
}


Javascript


Solidity
pragma solidity ^0.5.0;
 
contract helloGeeks {
 function renderHelloGeeks () public pure returns (string) {
   return 'Hello World';
 }
}


XML


  Hello World


ObjectiveC
#import
#import
  
int main(void)
{
    NSLog(@"Hello World
");
    return 0;
}


Kotlin
fun main(args: Array) {
    println("Hello World")
}


Dart
void main() {
  print('Hello World');
}


2. C++中的Hello World

C++

// Simple C++ program to
// display "Hello World"
 
// Header file for
// input output functions
#include 
 
using namespace std;
 
// main function -
// where the execution of
// program begins
int main()
{
    // prints hello world
    cout << "Hello World";
 
    return 0;
}

3. C#中的Hello World

C#

// C# program to print Hello World!
 
using System;
 
// namespace declaration
namespace HelloWorldApp {
 
// Class declaration
class Geeks {
 
    // Main Method
    static void Main(string[] args)
    {
 
        // statement
        // printing Hello World!
        Console.WriteLine("Hello World");
 
        // To prevents the screen from
        // running and closing quickly
        Console.ReadKey();
    }
}
}

4. Java的Hello World

Java

// This is a simple Java program.
// FileName : "HelloWorld.java"
 
class HelloWorld {
 
    // Your program begins
    // with a call to main().
    // Prints "Hello, World"
    // to the terminal window.
    public static void main(
        String args[])
    {
        System.out.println("Hello World");
    }
}

5. Python的Hello World

Python

# Python code for "Hello World"
 
print("Hello World")    

6. Perl中的Hello World

佩尔

#!/usr/bin/perl
 
# Modules used
use strict;
use warnings;
 
# Print function
print("Hello World\n");
 
# To run the code refer:
# http://bit.ly/2qLYVTG

7.斯卡拉的Hello World

斯卡拉

// Scala program to print Hello World!
 
object Geeks
{
 
    // Main Method
    def main(args: Array[String])
    {
 
        // prints Hello World
        println("Hello World")
    }
}

8. Go中的Hello World

// Go program to print Hello World!
 
package main
 
    import "fmt"
 
    // Main function
    func
    main()
{
 
    // prints Hello World
    fmt.Println("!... Hello World ...!")
}

9. PHP的Hello World

的PHP




 

 


10. HTML中的Hello World

的HTML


Hello World

11. JavaScript中的Hello World

的JavaScript


12.朱莉娅你好世界

茱莉亚(Julia)

// Julia program
println("Hello World")

13. R中的Hello World

[R

# Code
cat('Hello World')

14. Ruby中的Hello world

红宝石

# code
puts "Hello World"

15.扎实的世界你好

坚固性

pragma solidity ^0.5.0;
 
contract helloGeeks {
 function renderHelloGeeks () public pure returns (string) {
   return 'Hello World';
 }
}

16. XML的Hello World

XML格式



  Hello World

17.Objective -C中的Hello World

物镜

#import
#import
  
int main(void)
{
    NSLog(@"Hello World
");
    return 0;
}

18.在科特林的Hello World

科特林

fun main(args: Array) {
    println("Hello World")
}

19. Dart的Hello World

Dart

void main() {
  print('Hello World');
}

以下是所有语言的代码:

C

// Simple C program to
// display "Hello World"
 
// Header file for
// input output functions
#include 
 
// main function -
// where the execution of
// program begins
int main()
{
 
    // prints hello world
    printf("Hello World");
 
    return 0;
}

C++

// Simple C++ program to
// display "Hello World"
 
// Header file for
// input output functions
#include 
 
using namespace std;
 
// main function -
// where the execution of
// program begins
int main()
{
    // prints hello world
    cout << "Hello World";
 
    return 0;
}

C#

// C# program to print Hello World!
 
using System;
 
// namespace declaration
namespace HelloWorldApp {
 
// Class declaration
class Geeks {
 
    // Main Method
    static void Main(string[] args)
    {
 
        // statement
        // printing Hello World!
        Console.WriteLine("Hello World");
 
        // To prevents the screen from
        // running and closing quickly
        Console.ReadKey();
    }
}
}

Java

// This is a simple Java program.
// FileName : "HelloWorld.java"
 
class HelloWorld {
 
    // Your program begins
    // with a call to main().
    // Prints "Hello, World"
    // to the terminal window.
    public static void main(
        String args[])
    {
        System.out.println("Hello World");
    }
}

Python

# Python code for "Hello World"
 
print("Hello World")    

佩尔

#!/usr/bin/perl
 
# Modules used
use strict;
use warnings;
 
# Print function
print("Hello World\n");
 
# To run the code refer:
# http://bit.ly/2qLYVTG

斯卡拉

// Scala program to print Hello World!
 
object Geeks
{
 
    // Main Method
    def main(args: Array[String])
    {
 
        // prints Hello World
        println("Hello World")
    }
}

的HTML


Hello World

的PHP




 

 


茱莉亚(Julia)

println("Hello World")

红宝石

puts "Hello World"

[R

cat('Hello World')

package main
   
import "fmt"
   
// Main function
func main() {
   
    fmt.Println("Hello World")
}

Java脚本


坚固性

pragma solidity ^0.5.0;
 
contract helloGeeks {
 function renderHelloGeeks () public pure returns (string) {
   return 'Hello World';
 }
}

XML格式



  Hello World

物镜

#import
#import
  
int main(void)
{
    NSLog(@"Hello World
");
    return 0;
}

科特林

fun main(args: Array) {
    println("Hello World")
}

Dart

void main() {
  print('Hello World');
}

输出:

Hello World