
- Swift Tutorial
- Swift - Home
- Swift - Overview
- Swift - Environment
- Swift - Basic Syntax
- Swift - Data Types
- Swift - Variables
- Swift - Optionals
- Swift - Tuples
- Swift - Constants
- Swift - Literals
- Swift - Operators
- Swift - Decision Making
- Swift - Loops
- Swift - Strings
- Swift - Characters
- Swift - Arrays
- Swift - Sets
- Swift - Dictionaries
- Swift - Functions
- Swift - Closures
- Swift - Enumerations
- Swift - Structures
- Swift - Classes
- Swift - Properties
- Swift - Methods
- Swift - Subscripts
- Swift - Inheritance
- Swift - Initialization
- Swift - Deinitialization
- Swift - ARC Overview
- Swift - Optional Chaining
- Swift - Type Casting
- Swift - Extensions
- Swift - Protocols
- Swift - Generics
- Swift - Access Control
- Swift Useful Resources
- Swift - Compile Online
- Swift - Quick Guide
- Swift - Useful Resources
- Swift - Discussion
Swift program to print Hello World!
This tutorial will discuss how to write swift program to print Hello World.
Hello world programs are the most basic program of any programming language. It is used to learn how we can simply print “Hello world” on the screen using Swift language.
Example
Hello world program
The following program shows how to print hello world.
import Swift // Printing hello world print("Hello World")
Output
Hello World
Here we simply print hello world on the output screen using print() function. The syntax of Swift is quit easy and time saver. Like other languages you did not required to semicolon to end the statement. But you can use if you want to write multiple statements in the single line.
Note − To run this program make sure that Swift is properly installed in your system.
Basic elements of Swift Program
Import Libraries − In Swift, import keyword is used to import swift libraries. For example, import Swift is library is used to access all the symbols defined inside the swift language.
Syntax
Following is the syntax −
import libraryName
Comments − Comments are the non-executable text in our program that are used to make codes more understandable. They are always ignored by the Swift compiler. Single line comments are represented by (//) whereas multi line comments are enclosed in between (/*….*/)
Syntax
Following is the syntax −
//Single line comment And /* Multi Line comment */
print() − print() is in-built function which is used to print the result on the screen.
Syntax
Following is the syntax −
print(“Hello People”)
- Related Articles
- Python Program to Print Hello world
- Haskell Program to print Hello World!
- C Program to print “Hello World!” without using a semicolon
- How to print "Hello World!" using Python?
- C++ "Hello, World!" Program
- Print Hello World without semicolon in C++
- Hello World Program in Java
- Creating Java Hello World Program
- Hello World program in Kotlin
- Analysis of Java "Hello World" Program
- How to write "Hello, World!" program in JavaScript?
- How to write "Hello World" Program in C++?
- Internal Analysis of Java "Hello World" Program
- Print “Hello World” in C/C++ without using header files
- Print “Hello World” with empty or blank main in C++
