Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Swift Articles
Page 25 of 40
Swift program to convert string to an array
This tutorial will discuss how to write swift program to convert string to an array. String is an ordered collection of characters. For example − “TutorialsPoint”, “Pinky”, etc. To create a string type variable we use String keyword. var str : String Array is a collection of similar data types. Like any array of integer can contain only integer values, it does not accept string values. var arr = [Int] To convert string into an array we can use any of the following method. Below is a demonstration of the same − Input Suppose our given input is ...
Read MoreSwift program to print hollow rectangle star pattern
This tutorial will discuss how to write swift program to print hollow rectangle star pattern. Star pattern is a sequence of “*” which is used to develop different patterns or shapes like pyramid, rectangle, cross, etc. These star patterns are generally used to understand or practice the program flow controls, also they are good for logical thinking. To create a hollow rectangle star pattern we can use any of the following methods − Using nested for loop Using stride Function Below is a demonstration of the same − Input Suppose our given input is − Length = 10 ...
Read MoreSwift program to print 8 star pattern
This tutorial will discuss how to write swift program to 8 star pattern. Star pattern is a sequence of “*” which is used to develop different patterns or shapes like pyramid, rectangle, cross, etc. These star patterns are generally used to understand or practice the program flow controls, also they are good for logical thinking. To create a 8 star pattern we can use any of the following methods − Using nested for loop Using stride Function Below is a demonstration of the same − Input Suppose our given input is − Num = 5 Output The ...
Read MoreSwift 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 ...
Read MoreSwift program to find the reverse of a given number using recursion
This tutorial will discuss how to write swift program to find the reverse of a given number using recursion. Reversing a number is a process in which the position of the digits of a number is interchanged to reverse their order. To find the reverse of the number we use recursive approach. Recursive approach is an approach in which a function call itself to complete the specified task. Below is a demonstration of the same − Input Suppose our given input is − MyVal = 278938 Output The desired output would be − Reverse number = 839872 Method ...
Read MoreSwift program to display prime numbers between intervals using function
This tutorial will discuss how to write swift program to display prime numbers between intervals using function. Prime numbers are those numbers that are greater than 1 and has exactly two factors that is 1 and the number itself. For example, 7 is the prime number because it has only two factors that are 1 and 7. Below is a demonstration of the same − Input Suppose our given input is − Lower Interval = 18 Upper Interval = 42 Output The desired output would be − Prime numbers between 18 to 42 are 19 23 29 31 37 ...
Read MoreSwift program to convert double type variable to string
This tutorial will discuss how to write swift program to convert double type variable to int. Swift support various datatypes and double and string are one of them. String is an ordered collection of characters. For example: “TutorialsPoint”, “Pinky”, etc. To create a string type variable, we use String keyword. Whereas Double is used to represent 64-bit floating point numbers. For example, 34.55656, 9.8283, etc. To create a double type variable, we use Double keyword. To convert double type variable into string we uses String() function. This function convert any data type into string. Syntax Following is the syntax − ...
Read MoreSwift program to create a class and object
This tutorial will discuss how to write swift program to create a class and object. Swift language is also an object oriented language. So it fully support class and objects. Class A class is a blueprint for the objects. To add the functionality to the class we can define properties and methods. Here, the constants and variables present inside the class are known as the class property whereas a function present inside a class is known as a method. Just like other programming language, Swift classes also support inheritance, type casting, deinitializers, reference, etc. Syntax Following is the syntax to ...
Read MoreSwift program to convert double type variables to int
This tutorial will discuss how to write swift program to convert double type variable to int. Swift support various datatypes and double and integers are one of them. Double is used to represent 64-bit floating point numbers. For example, 34.55656, 9.8283, etc. To create a double type variable we use Double keyword. Whereas Integer represent numeric values like 2, 3, 45, 6, etc. And to create integer type variable we use Int keyword. To convert double type variable into int we uses Int() function. This function convert any data type into integer. Syntax Following is the syntax − Int(variableName) ...
Read MoreSwift Program to convert int type variable to string
This tutorial will discuss how to write swift program to convert int type variable to string. Swift support various datatypes and string and integers are one of them. String is an ordered collection of characters. For example: “TutorialsPoint”, “Pinky”, etc. To create a string-type variable we use String keyword. Whereas Integers represent numeric values like 2, 3, 45, 6, etc. And to create integer-type variables we use the Int keyword. To convert int type variable into string we uses String() function. This function convert any data type into string. Syntax Following is the syntax − String(variableName) Below is a ...
Read More