Triangle Pattern Program in Swift

Triangle pattern program in swift using asterisk . This is a basic set of programs in every programming language to print the pattern. This is helps you to print the triangle pattern in swift asterisk programming language

func pattern(_ int : Int)
for i in
print(String.init(repeating: " ", count: int-i) + String.init(repeating: "*", count: 2*i - 1))



Count in Swift Program

In Swift, utilise the array’s count function to find out how big it is. Here’s a brief example of how to count the number of elements in an array. array name is the name of the array variable. The size of this array is returned by count, which is an integer value.

Function in Swift Program

Functions are self-contained snippets of code that do a specific goal. This type can be used in Swift like any other type, making it simple to send functions as parameters to other functions and to return functions from functions. With this program we can execute triangle pattern program in swift.

For Loop Statement in Swift

The for-in loop in Swift is used to repeat a piece of code a specific number of times. It can iterate through any sequence, including an array, a range, a string, and so on. The for-in loop has the following syntax: for val in sequence / statements On each iteration, val accesses each item in the sequence.