Server Side Programming Articles

Page 1719 of 2109

Swift Program to Display Armstrong Number Between Two Intervals

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 540 Views

This tutorial will discuss how to write swift program to display Armstrong number between two intervals. The sum of nth power of individual digit of a number is equal to the number itself, then such type of number is known as Armstrong number. Suppose we have a number 407 so here n = 3 407 = 43 + 03 + 73 407 = 64 + 0 +343 407 =407 Hence 407 is Armstrong number Suppose we have another number 2346, so here n = 4 2346 = 24 + 34 + 44 + 64 2346 = 16 + 81 + ...

Read More

Swift Program to Find Geometric Mean of the Numbers

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 434 Views

This tutorial will discuss how to write swift program to find the geometric mean of the numbers. Geometric mean also known as GM. Geometric mean is defined as the xth root of the product of x numbers. Suppose we have x elements(that are, a1, a2, a3, ....ax) in the given array, then the geometric mean is − GM = (a1 * a2 * a3 * a4 * ....*ax)1/x Below is a demonstration of the same − Input Suppose our given input is − MyVal = [34, 67, 2, 45, 8, 12] Output The desired output would be − Geometric ...

Read More

Swift Program to Find Mean of an Unsorted Array

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 362 Views

This tutorial will discuss how to write swift program to find mean of an unsorted array. An array is an ordered collection which is used to store same type of data. For example, if any array is of integer type then it will only store integers, you are strictly not allowed to store elements of other data types like string, float, etc. Syntax Following is the syntax for an array − var array1 = [val1, val2, val3, …] Or var array2 = [Type]() Mean represent the average of the given numbers. It is calculated by dividing the sum of ...

Read More

Swift Program to Calculate the sum of Elements in a Given Array

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 4K+ Views

This tutorial will discuss how to write swift program to calculate the sum of elements in a given array. An array is an ordered collection which is used to store same type of data. For example, if any array is of integer type then it will only store integers, you are strictly not allowed to store elements of other data types like string, float, etc. Syntax Following is the syntax for an array − var array1 = [val1, val2, val3, …] Or var array2 = [Type]() Suppose we have an array of integer type: [20, 30, 40, 50]. Now ...

Read More

Swift Program to Remove All the Elements from the Array

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 1K+ Views

This tutorial will discuss how to write swift program to get the magnitude of the number. An array is an ordered collection which is used to store same type of data. For example, if any array is of integer type then it will only store integers, you are strictly not allowed to store elements of other data types like string, float, etc. To remove all the elements from the specified array Swift provide an in-built library function named removeAll(). The removeAll() function will delete all the items from the specified array. Or it can delete elements that match the given ...

Read More

Swift Program to Remove an Element from the Set

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 2K+ Views

This tutorial will discuss how to write swift program to remove an element from the set. Set is a primary collection type in Swift. It is an unordered collection which stores unique values of same data type. You are not allowed to store different type of values in the same set. A set can be mutable or immutable. To remove an element from the set Swift provide an in-built library function named remove(). The remove() function delete the given element from the specified set. If the given element is not the part of the specified set, then it will return ...

Read More

Swift Program to Add a New Element in the Set

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 250 Views

This tutorial will discuss how to write swift program to add a new element in the set. Set is a primary collection type in Swift. It is an unordered collection which stores unique values of same data type. You are not allowed to store different type of values in the same set. A set can be mutable or immutable. To add a new element in the set Swift provide the following functions − insert() update() Below is a demonstration of the same − Input Suppose our given input is − MySet = [23, 45, 1, 46, 2] Insert ...

Read More

Swift Program to Convert a String to Uppercase

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 3K+ Views

This tutorial will discuss how to write swift program to convert a string to uppercase. A string is a sequence of characters for example, “RedCar”. Or we can say, string are used to represent textual data. Swift support a String data type which is used to create a String type variable, or we can say to represent strings. To convert the given string into uppercase Swift provide a in-built function named uppercased(). The uppercased() function is used to convert all the characters(either in lowercase or in uppercase or in both) of the given string into uppercase. This function does not ...

Read More

Swift program to Get the Size of Set

Ankita Saini
Ankita Saini
Updated on 20-Oct-2022 603 Views

This tutorial will discuss how to write swift program to get the size of set. Set is a primary collection type in Swift. It is an unordered collection which stores unique values of same data type. You are not allowed to store different type of values in the same set. A set can be mutable or immutable. To get the size of a Set Swift provide an in-built property named count. It will return the total number of elements present in the specified count. Below is a demonstration of the same − Input Suppose our given input is − MySet ...

Read More

C++ Program to pass a string to the function

Arnab Chakraborty
Arnab Chakraborty
Updated on 19-Oct-2022 23K+ Views

Any programming language that uses functions has code that is simpler, more modular, and simpler to change while being debugged. Functions are a remarkably beneficial component in a modular piece of code. A function can take arguments and perform certain operations on them. Like other primitive datatypes, we can also pass object types or arrays as an argument. In this article, we will see how to pass string-type data as a function argument in C++. Passing C++ like string argument to a function C++ supports stronger string objects which is actually a class with different member functions associated with them. ...

Read More
Showing 17181–17190 of 21,090 articles
Advertisements