斯威夫特山地车_斯威夫特| 打印“ Hello World”程序

斯威夫特山地车

Swift is a language that is used to create an application for the iOS software included in Apple products. It was derived from the objective C and is an Object Oriented programming language. Let us start with the basic program of Swift i.e. Hello World.

Swift是一种语言,用于为Apple产品中包含的iOS软件创建应用程序。 它源自目标C,是一种面向对象的编程语言。 让我们从Swift基本程序即Hello World开始

This program will give you an idea of the syntax and how we can display the output on the screen. Like any other language, Swift also has a software i.e. XCode, where the program is run and commands are executed.

该程序将为您提供语法概念以及如何在屏幕上显示输出。 像任何其他语言一样,Swift也有一个软件,即XCode ,可以在其中运行程序并执行命令。

Open XCode terminal and type the following program

打开XCode终端并键入以下程序

import Foundation
print("Hello, World!");

Hit enter key to run the program and the output will be shown.

按Enter键运行程序,将显示输出。

Output

输出量

Hello, World!

Screenshot with code and the output i.e. Xcode terminal

屏幕截图,带代码和输出,即Xcode终端

Explanation:

说明:

Here, printf function is used to show the text quoted in " " on the output screen as in C.

在这里, printf函数用于在输出屏幕上像C一样显示在“”中引用的文本。

Semicolon ";" is the must after every end of the command as similar in C/C++ etc.

分号“;” 与C / C ++等类似,是命令每一行之后的必需内容。

// is used to comment in a program as depicted above.

//用于在程序中如上所述进行注释。

import Foundation is a library which is used to access all the functions present that header file.

import Foundation是一个库,用于访问该头文件中提供的所有功能。

There can be many such header files that can be imported.

可以导入许多此类头文件。

Whereas, "program ended with exit code: 0" at the end shows that there are no further programs to be run.

结尾处的“程序以退出代码0结尾”表示没有其他程序要运行。

Stay connected with us to know more about Swift coding in our further tutorials.

与我们保持联系,以在进一步的教程中进一步了解Swift编码。

翻译自: https://www.includehelp.com/swift/print-hello-world-program.aspx

斯威夫特山地车

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值