Swift | Print 'Hello World' program

Swift program to print 'Hello World': Here, we are going to implement our first program in Swift programming language.
Submitted by Mahima Rao, on September 25, 2018

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.

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.

Open XCode terminal and type the following program

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

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


Hello, World!

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


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

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

// 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.

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.

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


Comments and Discussions!

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.