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 26 of 40
Swift Program to Print Hollow Right Triangle Star Pattern
This tutorial will discuss how to write swift program to print hollow right triangle 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 right triangle 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 = ...
Read MoreSwift Program To Print X Star Pattern
This tutorial will discuss how to write swift program to print X 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 X 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 desired ...
Read MoreHow to improve the readability of Swift code?
In this tutorial, you will learn how to improve code readability in the Swift language. You can follow a variety of techniques when writing code. By following these methods, you will be able to write more understandable code for yourself and other developers. Use Comments This is the most important thing we should do. When writing code, we often write logic and calculations. When we start, we have everything in our minds, but after a month, it's definitely difficult to remember everything, especially in large applications. The code is usually commented on single lines. As a result, we are better ...
Read MoreWhat is the use of the double question mark "??" in Swift?
In this tutorial, you will learn the use of double question marks (?) in the Swift language. In Swift, a double question mark (??) is called the "nil−coalescing operator". This operator is basically used to provide a default value in the case of nil. In other words, when a variable is nil and you want to provide a default value in the absence of a value, use this operator. According to Apple documentation The nil-coalescing operator (a ?? b) unwraps an optional a if it contains a value, or returns a default value b if a is nil. The expression ...
Read MoreName Some Advantages of Using Swift
This article will explain to you the advantages of using the Swift programming language. Introduction of the Swift language Swift is a clean and concise programming language that is growing fast and becoming increasingly popular. Swift was initially used for iOS development but has become very popular for many other things like macOS, watchOS, and server-side development. Apple introduced the Swift language as an open-source programming language as a replacement for Objective−C, C, and C++. The Swift language was created in 2014 and released publicly in 2015 by Apple Inc. We can say Swift is a modern programming language like ...
Read MoreExplain the difference between let and var in Swift
This article will explain the difference between let and var in the Swift language. Most of the time, we deal with different data types in any programming language. However, we need to identify values by name. These names are called variables. Like C, Swift uses variables to store and refer to values by an identifying name. Swift also makes extensive use of variables whose values can’t be changed. These are known as constants. They are more powerful than constants in C. Constants are used throughout Swift to make code safer and clearer in intent. This is because you work with ...
Read MoreSwift Program to Convert Char type variables to Int
This tutorial will discuss how to write swift program to convert char type variable to int. Swift support various datatypes and character and integers are one of them. Character represent single-character string like, “2”, “a”, “l”, etc. Whereas Integer represent numeric values like 2, 3, 45, 6, etc. To convert char type variable into Int type we can use any of the following method. Method 1 - Using whole Number Value Property We can convert char type variable into Int type using whole Number Value property. This property will convert character into number value if the character represent a ...
Read MoreSwift Program to Calculate Cube Sum of First n Natural Numbers
This tutorial will discuss how to write swift program to calculate cube sum of first n natural numbers. Natural numbers are those number which include all the positive number starting from 0 to infinite for example, 1, 2, 3, 4, ……n. Now we find the cube sum of first n natural numbers: 1+23+33+43 = 1 + 8 + 27 + 64 = 100. Below is a demonstration of the same − Input Suppose our given input is − Num = 5 Output The desired output would be − Cube Sum of first 5 numbers are 225. Algorithm Following ...
Read MoreSwift Program to Calculate Area and Perimeter of Equilateral Triangle
This tutorial will discuss how to write swift program to calculate area and perimeter of equilateral triangle A triangle whose all sides and angles are equal is known as the equilateral triangle. Each angle of equilateral triangle is 60 degrees. It is also known as 3-side polygon. Area of Equilateral Triangle The amount of space occupied between the three lines of the triangle is known as the area of the equilateral triangle. Formula Following is the formula − Area = √3x2/ 4 Here x is the side of the equilateral triangle. Below is a demonstration of the ...
Read MoreSwift Program to Find the Mid-point of a Line
This tutorial will discuss how to write swift program to find the mid-point of a line. A point lies between the middle of two points is known as mid-point. Suppose we have two points A and B and C point is the mid-point located between A and B. Midpoint always divide lines segment in equal parts. Or we can say mid-point is always equidistant from other two points. Formula Following is the formula − Midpoint = ((a1+a2)/2, (b1+b2)/2) Below is a demonstration of the same − Input Suppose our given input is − Point 1: (5.0, 6.0) ...
Read More