Found 33676 Articles for Programming

C++ Program to get the imaginary part of the given complex number

Arnab Chakraborty
Updated on 12-Dec-2022 16:18:07

1K+ Views

Modern science relies heavily on the concept of complex numbers, which was initially established in the early 17th century. The formula for a complex number is a + ib, where a and b are real values. A complex number is known to have two parts: the real component (a) and the imaginary part (ib). The i or iota has the value √-1. The complex class in C++ is a class that is used to represent complex numbers. The complex class in C++ can represent and control several complex number operations. We take a look at how to represent and display ... Read More

What are the new features in Swift 4.0?

Nitin Aggarwal
Updated on 05-Jan-2023 10:47:31

451 Views

In this tutorial, you are going to learn what changes have been released in Swift 4. Every time, Apple releases major versions with lots of improvements and additions to APIs. The new features introduced in Swift 4.0 include improved key paths for key-value coding, encoding and decoding, multi-line string literals, Strings are collections, improved dictionary functionality, one-sided ranges, and many other code enhancements. Encoding & Decoding In Swift 4.0, Apple introduced the Codable protocol to make encoding and decoding easy for developers. You can implement serialization and deserialization in your code using this protocol. You can encode and decode your ... Read More

What are the higher-order functions in Swift?

Nitin Aggarwal
Updated on 09-Dec-2022 12:55:28

6K+ Views

Throughout this tutorial, you will learn about the higher-order functions available in Swift. You will find out what they are used for and how to use them. What are they? A higher-order function is a function that takes one or more functions as arguments or returns a function as its result. Below are the higher-order functions provided by the Swift language − forEach() map() compactMap() flatMap() filter() reduce() sort() sorted() All the higher-order functions are based on closure but don't worry you don't need to be a master of closure. They are easy to use and also reduce ... Read More

How to improve the readability of Swift code?

Nitin Aggarwal
Updated on 09-Dec-2022 12:49:59

190 Views

In this tutorial, you will learn how to improve code readability in the Swift language. You can follow a variety of techniques when writing code. By following these methods, you will be able to write more understandable code for yourself and other developers. Use Comments This is the most important thing we should do. When writing code, we often write logic and calculations. When we start, we have everything in our minds, but after a month, it's definitely difficult to remember everything, especially in large applications. The code is usually commented on single lines. As a result, we are better ... Read More

Explain generics and How to apply method or variable generics in Swift?

Nitin Aggarwal
Updated on 09-Dec-2022 12:45:50

249 Views

In this tutorial, you are about to learn how you can use generics to make your code reusable and flexible in an application. You will see how to create functions and properties that can work with any type with an example. What is generics? Swift allows you to write flexible, reusable code using generics. Generic code can work with any type. You can write code that avoids duplication and expresses its intent in a clear, abstract manner. Generics are one of the most powerful features of Swift, and much of the Swift standard library is built with generic code. You’ve ... Read More

What is the use of the double question mark “??” in Swift?

Nitin Aggarwal
Updated on 09-Dec-2022 12:40:28

3K+ Views

In this tutorial, you will learn the use of double question marks (?) in the Swift language. In Swift, a double question mark (??) is called the "nil−coalescing operator". This operator is basically used to provide a default value in the case of nil. In other words, when a variable is nil and you want to provide a default value in the absence of a value, use this operator. According to Apple documentation The nil-coalescing operator (a ?? b) unwraps an optional a if it contains a value, or returns a default value b if a is nil. The expression ... Read More

What is the difference between class and structure in Swift?

Nitin Aggarwal
Updated on 09-Dec-2022 12:36:25

12K+ Views

This guide will cover what classes and functions there are in the Swift programming language. Also, what are the differences between them? Most of the time, when we write code in a project, we have to deal with classes and structures. It is true that these two features are the most significant in Swift. In a real−time application, whatever you want to write, you need to create a class to assign responsibility. If we already have a class option, we need to understand why and when we should use the structure. Structures are one of the fundamental concepts in the ... Read More

Mention the tools required to develop iOS applications

Nitin Aggarwal
Updated on 09-Dec-2022 12:28:27

378 Views

In this tutorial, we are going to study about different types of tools required to develop iOS applications. As we already know, there are approximately 1 billion iPhone users. Thus, Apple always provides a hassle−free environment for developers who want to build applications for iPhone, iPad, MacBook, and Apple Watch. Apple has built a strong ecosystem for developers so they can focus on writing code and building apps. Today, we will see what tools we need to develop applications on the Apple platform. Xcode This is an editor or IDE to write code for building apps. Apple released the ... Read More

Name Some Advantages of Using Swift

Nitin Aggarwal
Updated on 09-Dec-2022 12:24:03

847 Views

This article will explain to you the advantages of using the Swift programming language. Introduction of the Swift language Swift is a clean and concise programming language that is growing fast and becoming increasingly popular. Swift was initially used for iOS development but has become very popular for many other things like macOS, watchOS, and server-side development. Apple introduced the Swift language as an open-source programming language as a replacement for Objective−C, C, and C++. The Swift language was created in 2014 and released publicly in 2015 by Apple Inc. We can say Swift is a modern programming language like ... Read More

Explain the difference between let and var in Swift

Nitin Aggarwal
Updated on 09-Dec-2022 12:20:52

4K+ Views

This article will explain the difference between let and var in the Swift language. Most of the time, we deal with different data types in any programming language. However, we need to identify values by name. These names are called variables. Like C, Swift uses variables to store and refer to values by an identifying name. Swift also makes extensive use of variables whose values can’t be changed. These are known as constants. They are more powerful than constants in C. Constants are used throughout Swift to make code safer and clearer in intent. This is because you work with ... Read More

Advertisements