In this tutorial you will learn about the Swift Hello World and its application with practical example.
Swift Hello World Program
The “Hello world!” program is a simplest program that will display some text on the screen. The “Hello world!” program is a simple yet complete program for beginners that illustrates the basic syntax of any programming language. The “Hello world!” program gives you a way to test systems and programming environment.
This tutorial will guide you through writing a basic “Hello, World” program in Swift Programming.
Step 1:- Create a file called “hello_world.swift” using a text editor program of your choice. The .swift file extension is used to specify swift language file.
Step 2:- Let’s open the “hello_world.swift” file that we created, and put the following line of code in it and save it.
1 |
print("Hello world") |
The print() is a function that tells Swift to display or output the content inside the parentheses.
Step 3:- Now, run the following command to compile and run the swift program
1 2 |
$ swiftc hello_world.swift $ ./hello_world |
Once the program is executed it will print “Hello, World”.
Output:-
1 |
Hello, World |