网站宽度960,华跃建筑人才网,做网站定金交多少合适,网站 移动化斯威夫特山地车In this program, we will have an idea - how two numbers can be added and displayed as the output on the screen? 在此程序中#xff0c;我们将有一个想法- 如何将两个数字相加并显示为屏幕上的输出 #xff1f; Open XCode terminal and type the fol…斯威夫特山地车In this program, we will have an idea - how two numbers can be added and displayed as the output on the screen? 在此程序中我们将有一个想法- 如何将两个数字相加并显示为屏幕上的输出 Open XCode terminal and type the following program 打开XCode终端并键入以下程序 import Foundation
var num1 4;
var num2 6;
var ans Int();
ans num1num2;
print(num1 num2 ,ans);
Output 输出量 num1 num2 10
Program ended with exit code: 0
Explanation: 说明 import Foundation is a library which is used to access all the functions present that header file. import Foundation是一个库用于访问该头文件中提供的所有功能。 var is a data type with num1 as a variable whose value is initialized as 4. Similarly, num2 is a variable with same data type whose value is initialized as 6. var是一种数据类型以num1作为变量其值初始化为4 。 同样 num2是具有相同数据类型的变量其值初始化为6 。 Whereas, var ans includes same data type with ans as a variable where the result is stored. 而var ans包含与ans相同的数据类型而ans作为存储结果的变量。 print function prints the string with the answer on the output screen. 打印功能在输出屏幕上打印带有答案的字符串。 Whereas, program ended with exit code: 0 at the end shows that there are no further programs to be run. 而结尾处的“程序以退出代码0结尾”表示没有其他程序要运行。 Semicolon ; is must after every end of the command as similar in C/C etc. 分号“;” 在命令的每个结尾之后必须是类似于C / C 等。 翻译自: https://www.includehelp.com/swift/addition-of-two-numbers.aspx斯威夫特山地车