Ankita Saini has Published 319 Articles

Swift program to Convert Celsius to Fahrenheit

Ankita Saini

Ankita Saini

Updated on 16-Jun-2023 11:31:14

534 Views

Fahrenheit is the commonly used temperature-measuring unit. In this scale, the freezing point and boiling point of the water are 32 degrees and 212 degrees. Whereas Celsius is also a temperature-measuring scale. In the Celsius scale, the freezing point and the boiling point of the water are 0 degrees and ... Read More

Swift program to Convert Fahrenheit to Celsius

Ankita Saini

Ankita Saini

Updated on 16-Jun-2023 11:23:45

419 Views

Fahrenheit is the commonly used temperature-measuring unit. In this scale, the freezing point and boiling point of the water are 32 degrees and 212 degrees. Whereas Celsius is also a temperature-measuring scale. In the Celsius scale, the freezing point and the boiling point of the water are 0 degrees and ... Read More

Swift program to find the longest word in a string

Ankita Saini

Ankita Saini

Updated on 15-Jun-2023 17:03:32

354 Views

In Swift, a string is a sequence of characters. So a string can contain small and larger words. Hence using the following methods we can find the largest word in the string. Using component() method Using user-defined method Example Input String: "Rabbit run fast" Output String: "Rabbit" ... Read More

Swift program to generate a password

Ankita Saini

Ankita Saini

Updated on 15-Jun-2023 16:35:50

270 Views

A password is a combination of various characters of a specified length and is used to authenticate or gain access to the system or login to an account. It is designed for security purposes and ensures that only an authorized user can access or log in to the specific account. ... Read More

Swift program to generate an OTP

Ankita Saini

Ankita Saini

Updated on 15-Jun-2023 16:16:30

251 Views

An OTP is known as a one-time password. It is an automatically generated random numeric string which is used for a single login session or transaction on digital devices. It is generally used to enhance security by providing extra authentication. For example, “423193”, “489201’, etc. To generate OTP Swift provides ... Read More

Swift Program to Replace a Character at a Specific Index

Ankita Saini

Ankita Saini

Updated on 14-Jun-2023 16:39:54

1K+ Views

To replace a character at a specified index with a new character Swift support the following methods − Using replaceSubrange() method. Using the append() method. Using replacingCharacters(in:with:). Using these methods you can replace any character from the given string with a new character. For Example Input: ... Read More

Swift Program to Remove leading zeros

Ankita Saini

Ankita Saini

Updated on 14-Jun-2023 16:35:37

659 Views

While working with strings sometimes we encounter some numeric strings whose leading numbers are zeros, e.g. 000003232, 00321, etc. To remove leading zeros from a numeric string − Using removeFirst() and hasPrefix() methods Using firstIndex() and dropFirst() methods Example Input: String = "000003231" ... Read More

Swift Program to Print first letter of each word using regex

Ankita Saini

Ankita Saini

Updated on 14-Jun-2023 15:03:30

116 Views

In Swift, regex is known as a regular expression. It is used to create a pattern which helps in matching or extracting some specific port of the given string. We can create a regex instance with the help of a regular expression in regex literal or string. In this article, ... Read More

Swift Program to demonstrate the example to write double-quotes in a string

Ankita Saini

Ankita Saini

Updated on 14-Jun-2023 14:43:16

93 Views

In Swift, a string is a sequence of characters that represent in between double quotes, for example: ”Learn Swift”, “tutorialspoint”, etc. But when you print the string double quotes were removed by the compiler and you will get Learn Swift, tutorialspoint in the output. So if you want to ... Read More

Swift Program to demonstrate the escape sequence characters

Ankita Saini

Ankita Saini

Updated on 14-Jun-2023 14:38:06

149 Views

In Swift, escape sequence characters are those characters who do not represent themselves when they are used inside a string. Instead, they tell the compiler to perform the specified task. They are non-printable characters. Swift supports the following escape sequence characters in the string − Escape Sequence ... Read More

Advertisements