
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

1K+ Views
In this article, we will learn how to write a swift program to remove all ‘nil’ elements from the array. Till now we all know that an array can store elements of a single data type. But Swift array can also hold elements of multiple data types. To store multiple data types in the array we use [Any], where [Any] specifies that the address can hold elements of any data types. Similarly an array also contain nil value. Here we use the following methods to remove nil elements from the array. Using compactMap() function Using filter() function ... Read More

2K+ Views
In this article, we will learn how to write a swift program to find the prime numbers from the array. Prime numbers are those numbers that are only divisible by 1 and itself. Or we can say prime number have only two factors that are 1 and the number itself. For example, 1, 2, 7, 3, 11, 31, etc. So to find the prime numbers from the given array, we individually check each element of the given array is prime or not. Algorithm Step 1 − Create a function. Step 2 − Check if the number is greater than ... Read More

2K+ Views
In this article, we will learn how to write a swift program to find even numbers from the array. Even number are those number which are completely divisible by 2. For example, 2, 6, 50, 20, etc. Here we use the following methods to find the even numbers from the array. Using for-in loop Using filter() function Method 1: Using for-in loop To find the even numbers from the given array we use for-in loop. Using for-in loop we iterate through each element of the given array and check if the element is even number or not. ... Read More

458 Views
In this article, we will learn how to write a swift program to fetch elements from an array based on an index. Using array syntax An array is used to store elements of same data type in an order whereas a set is used to store distinct elements of same data type without any definite order. In an array, every element has an index. The array index is start from 0 and goes up to N-1. Here N represent the total number of array elements. To retrieve elements from the array according to their index we can use subscript syntax. ... Read More

2K+ Views
In this article, we will learn how to write a swift program to convert set of string to array of string. An array is used to store elements of same data type in an order whereas a set is used to store distinct elements of same data type without any definite order. Now to convert a set of string to an array of string we use the following two methods − Using Array() initializer Using map() function Method 1: Using Array() Initializer To convert a set of string to an array of string we can use Array() initializer. ... Read More

1K+ Views
In this article, we will learn how to write a swift program to append an element into an array. An array is used to store elements of same data type in an order whereas a set is used to store distinct elements of same data type without any definite order. Here we use the following methods to append an element into an array − Using append(_:) function Using operator Method 1: Using append(_:) function To append an element in the array we uses append( function. The append(_:) function adds a new element at the end of the array. ... Read More

6K+ Views
In this tutorial, we will execute the program of removing all the elements of array using different set of examples. An array is a well-defined collection of elements stored at contiguous memory locations. The output is printed in the screen using fmt.Println() function. Let’s see few examples to get a clear understanding of this concept. Syntax func append(slice, element_1, element_2…, element_N) []T The append function is used to add values to an array slice. It takes number of arguments. The first argument is the array to which we wish to add the values followed by the values to ... Read More

2K+ Views
In this tutorial, we will discuss how to obtain the first and last element from a slice. A slice is a dynamic-sequence that stores elements of a similar type. It is similar to array but it can be resized whereas an array is of fixed range. Let’s understand the concept using some examples. Method 1: Using integer values In this method, we will use integer values to get the first and last element from a slice. The output will be printed on the screen using fmt.Println() function. Let’s go through the example to understand how it can be done. Algorithm ... Read More

3K+ Views
In this tutorial, we will learn how to compare elements in two slices. In slices a simple equality comparison is not possible so the slices are compared with their lengths and the elements present in the loop. The output will be printed in the form of Boolean value on the console with the help of fmt.Println() function. Let’s see how to execute this with the help of an example. Method 1: Using a user-defined function In this method, we will compare elements in two slices using an external function and, in that function, we will set some conditions, if the ... Read More

4K+ Views
In this tutorial, , we will grasp how to replace elements in a slice using different set of examples. A slice is a dynamic array which means that its value is not fixed like array. The output will be printed on the screen using fmt.Println() function. Let’s see how it can be implemented with crystal-clear examples. Method 1: Using built-in copy function In this method, we will use the built-in function copy to replace elements in slice which means at the place of original element and new element will be placed. The built-in functions shorten the code and easily solve ... Read More