- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 517 Articles for Swift
176 Views
A strong number is a special number in which the sum of the factorial of its digit is equal to the number itself. For example − Number = 345 345! = 3! + 4! + 5! = 6 + 24 + 120 = 150 Here 345 is not a strong number because the sum of the factorial of its digit is not equal to the number itself. Number = 145 145! = 1! + 4! + 5! = 1 + 24 + 120 = 145 Here 145 is a strong number because the sum of the factorial of its ... Read More
498 Views
1’s complement of a binary number is the invert of the given number. For example, we have a number = 10101011, so the one’s complement is 01010100. Here we using the following two methods to find one’s complement − Replacing 1s with 0s and 0s with 1s Using XOR In this article, we will learn how to write a swift program to find the 1’s complement of the given number. Method 1: Replacing 1s with 0s and 0s with 1s It is the smallest method to find ons complement of the given number. Here we simply convert the given number ... Read More
6K+ Views
An array is used to store elements of the same data type in an order whereas a set is used to store distinct elements of the same data type without any definite order. To convert Array into set we use Set() initialiser. The resultant set contains the same elements as the original array but with no order and no duplicate elements. In this article, we will learn how to convert Array to Set using Swift programming language. Algorithm Step 1 − Create an array of integer type. Step 2 − Print the array. Step 3 − Convert array into ... Read More
122 Views
Heterogram string is a string in which no alphabet occurs more than once. For example, “Sky with cloud” is a heterogram because in the string each alphabet occurred only once. Whereas “colorful balloons” is not a Heterogram because in the string some alphabet like o, u, l, etc appears more than once. Here we will execute different examples that will check whether the given string is heterogram or not using swift programming language. Algorithm Step 1 − Create a function. Step 2 − Remove the white space from the string. Step 3 − Create a separate array to ... Read More
433 Views
Pangram string is a string that contains all the English alphabet. For example − String = “The quick brown fox jumps over the lazy dog” Here the string is a pangram string which contains all the alphabetical characters from a to z in it. String = “ Hello! Swati how are you?” Here the string is not a pangram string because it does not contain all the 26 alphabetical characters from a to z. In this article, we will learn how to write a swift program to check if a string is pangram or not. So to check if the ... Read More
3K+ Views
A palindrome array is an array that remains the same when its elements are reversed we can also say that the elements of a palindrome array remain the same even if we read it from backward or forward. For example, [1, 9, 10, 9, 1] is a palindrome array whereas [3, 5, 7, 8, 3, 2, 1] is not a palindrome array. In this article, we are going to learn different methods of finding whether the given array is a palindrome or not suing Swift programming language. Algorithm Step 1 − Create a function. Step 2 − Reverse the ... Read More
211 Views
Keywords are reserved words used to perform some internal process or represent predefined actions. It is not allowed to use these keywords as a variable name, constant name, or identifier. Swift support approx 101 keywords. For example, ‘var’ is a keyword but ‘hey’ is not a keyword. Here, we will learn how to write a swift program to check whether a given string is a keyword. Algorithm Step 1 − Create an array of string types to store all the keywords supported by Swift. Step 2 − Create a function to check if the given string is a ... Read More
182 Views
In this article, we will learn how to write a swift program to remove the last given number of items from the array. An array is used to store elements of same data type in an order. So, here we use the following methods to remove the last given number of items from the array − Using removeLast(_:) function Using dropLast(_:) function Using removeSubrange() function Method 1: Using removeLast(_:) Function Swift provide an in-built function named as removeLast() function to remove the specified number of items from the end of the array. Syntax func removeLast(_x: Int) ... Read More
307 Views
In this article, we will learn how to write a swift program to remove the first given number of items from the array. An array is used to store elements of same data type in an order. So, here we use the following methods to remove the first given number of items from the array − Using removeFirst(_:) function Using dropFirst(_:) function Using removeSubrange() function Method 1: Using removeFirst(_:) Function Swift provide an in-built function named as removeFirst() function to remove the specified number of items from the start of the array. Syntax func removeFirst(_x: Int) ... Read More
1K+ Views
In this article, we will learn how to write a swift program to print object of a class. A class object is known as an instance of a class. For example, colour is a class then obj1, obj2, obj3 and obj4 are the objects from the class. A class can have multiple objects. Syntax var objectname = Classname() Here, using the above syntax we can create an object of a class. Algorithm Step 1 − Create a class with properties and a constructor. Step 2 − Create a function to print the object of the given class. Step ... Read More