Programming Articles - Page 574 of 3363

Swift Program to Convert a String to Uppercase

Ankita Saini
Updated on 20-Oct-2022 08:03:38

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 Convert a String to Lowercase

Ankita Saini
Updated on 20-Oct-2022 08:02:29

2K+ Views

This tutorial will discuss how to write swift program to convert a string to lowercase. 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 lowercase Swift provide a in-built function named lowercased(). The lowercased() function is used to convert all the characters(either in lowercase or in uppercase or in both) of the given string into lowercase. This function does not ... Read More

Swift Program to Get a Random Element from the Set

Ankita Saini
Updated on 20-Oct-2022 08:00:35

1K+ Views

This tutorial will discuss how to write swift program to get a random 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. Syntax Following is the syntax for Set − var name : Set = [element1, element2, element3] To get a random element from the Set Swift provide an in-built function named randomElement(). This function return a random element from the given ... Read More

Swift program to Get the Size of Set

Ankita Saini
Updated on 20-Oct-2022 07:57:34

552 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

How to create a sparse Matrix in Python?

Vikram Chiluka
Updated on 20-Oct-2022 08:50:33

8K+ Views

In this article, we will show you what is a sparse matrix and how to create a sparse matrix in python. What is a sparse matrix? A sparse matrix is one in which most of the elements are 0. That is, the matrix only contains data in a few positions. And most of the memory consumed by a sparse matrix is made up of zeroes. For example − M = [ [1, 0, 0, 0], [0, 0, 3, 0], [0, 0, 0, 0], [0, 0, 0, 2] ] ... Read More

C++ Program to Convert Vector to a List

Arnab Chakraborty
Updated on 19-Oct-2022 12:37:53

2K+ Views

Vectors in C++ are dynamic arrays that can contain any type of data, it can be user-defined or primitive. Dynamic is in the sense that the size of a vector can increase or decrease according to the operations. Vectors have support for various functions, for which data manipulation is very easy. Lists on the other hand are containers same as vectors, but list implementation is based on doubly linked lists compared to the array implementation of vectors. Lists offer the same constant time operations anywhere in it, that is the main feature of using lists. We take a look at ... Read More

C++ Program to Convert Array to Set (Hashset)

Arnab Chakraborty
Updated on 19-Oct-2022 11:22:52

5K+ Views

The array is a data structure that is available in C++ and is used to hold a sequential collection of elements of the same type. An array has a size that is fixed, but can be expanded or shrank if needed. It is important to think of an array as a collection of variables of the same type even though it is used to store a collection of data. Sets, or in this case unordered sets are a container that stores elements of a particular datatype in any order. A hash table is used to implement an unordered_set where keys ... Read More

C++ Program to convert primitive types to objects

Arnab Chakraborty
Updated on 19-Oct-2022 11:21:14

1K+ Views

Primitive datatypes in C++ are datatypes that are predefined in the language itself; like int, float, double, etc. Objects are instances of a class, and C++ being an object-oriented language, conversion between primitive data types and objects is necessary. A class serves as a data type's architectural plan. Although this doesn't describe any data specifically, it does specify what the class name signifies, i.e., what an object of the class will look like and what operations may be carried out on it. Conversion between a primitive data type to an object is not defined explicitly in the C++ language compilers, ... Read More

C++ Program to convert double type Variables into int

Arnab Chakraborty
Updated on 19-Oct-2022 11:17:09

3K+ Views

In C++, variables of the int type can only hold positive or negative integer values; they cannot hold fractional values. There are float and double values available for this purpose. In order to store fractional numbers with up to seven digits after the decimal point, double datatype was created. Integer to double datatype conversion can either be done automatically by the compiler (known as "implicit" conversion) or explicitly requested by the programmer to the compiler (known as "explicit" conversion). In the sections that follow, we go over the various conversion methods. Implicit Conversion The compiler does implicit type conversions automatically. ... Read More

C++ Program to convert int Variables into double

Arnab Chakraborty
Updated on 19-Oct-2022 11:14:22

12K+ Views

Int type variables in C++ are used to contain positive or negarive integer values, but this type is unable to contain fractional values. For that, there are float and double values. Double datatype is specifically designed to hold fractional values upto seven digits after the decimal point. Conversion between integer and double variables can be automatically handled by the compiler, known as ‘implicit’ conversion or can be explicitly triggered by the programmer to the compiler. We discuss the different ways of conversion in the following sections. Implicit Conversion Implicit type conversions are done automatically by the compiler. For this to ... Read More

Advertisements