Ankita Saini has Published 319 Articles

Swift Program to Print an Array

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 11:17:05

4K+ Views

This article will teach us how to write a swift program to print an array. To print an array, we are using the following methods − Using array name Using for loop Using a while loop Using forEach() method Method 1: Print the array using the array name We ... Read More

Swift Program to Print a 2D Array

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 11:04:39

1K+ Views

This article will teach us how to write a swift program to print a 2D array. Here we use the following methods − Using array name Using nested for loop Using subscript. Using forEach() method. Method 1: Print the 2D array using the array name We can print ... Read More

Swift Program to Find Common Array Elements

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 10:56:51

822 Views

This article will teach us how to write a swift program to find common array elements. So here we use the following methods − Using the filter method Using sets But before moving to the methods, we first understand common elements with the help of an example. Suppose we ... Read More

Swift Program to Count the elements of an Array

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 10:53:35

197 Views

In this article, we will learn how to write a swift program to count the elements of an array. To count the elements of an array swift provide a count property. This property will return the total number of elements present in the specified array. For example − Arr ... Read More

Swift Program to Check if Two Arrays Are Equal or Not

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 10:50:47

3K+ Views

In this article, we will learn how to write a swift program to check whether two arrays are equal. To check if two arrays are equal to not either, we are going to use the following two methods − using == operator elementsEqual(_:) method. Both method and ... Read More

Swift Program to Check if an array is empty

Ankita Saini

Ankita Saini

Updated on 20-Dec-2022 10:38:52

3K+ Views

In this article, we will learn how to write a swift program to check if an array is empty. Here we use two methods: Using isEmpty property Using conditional statements Method 1: Using isEmpty Property To check if an array is empty Swift provides an isEmpty property. This ... Read More

Swift program to print pascal’s triangle

Ankita Saini

Ankita Saini

Updated on 13-Dec-2022 16:33:25

304 Views

This tutorial will discuss how to write swift program to print Pascal’s triangle. A pascal’s triangle is a triangular array of the binary coefficient. It is a never ending equilateral triangle which always follows the rule of adding two numbers from the above row to get the number of below ... Read More

Swift program to check whether a number can be expressed as sum of two prime numbers

Ankita Saini

Ankita Saini

Updated on 13-Dec-2022 15:31:37

110 Views

This tutorial will discuss how to write swift program to check whether a number can be expressed as a sum of two prime numbers. 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 ... Read More

Swift program to get the remainder of float numbers using library function

Ankita Saini

Ankita Saini

Updated on 13-Dec-2022 14:59:47

197 Views

This tutorial will discuss how to write swift program to get the remainder of float numbers using library function. A number with fractional component is known as float numbers. For example, 34.5, 2.1, 0.2, etc. We can divide two float numbers with each other to find the remainder and quotient. ... Read More

Swift program to print spiral pattern

Ankita Saini

Ankita Saini

Updated on 13-Dec-2022 14:55:44

239 Views

This tutorial will discuss how to write swift program to print spiral pattern. Numeric pattern is a sequence of numbers which is used to develop different patterns or shapes like pyramid, rectangle, cross, etc. These numeric patterns are generally used to understand or practice the program flow controls, also they ... Read More

Advertisements