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
Server Side Programming Articles - Page 502 of 2650
14K+ Views
This tutorial will discuss how to write a swift program to swap two numbers without using temporary variable. Swapping of two variables means mutually exchanging the values of two variables.Swapping two numbers without using temporary variablesGiven two variables Number1 and Number2 now we swap their values without using any temporary variable. Here we use tuple to preform the swapping operation.AlgorithmThe algorithm is explained below −Step 1 − Declare two integer variables − Number1, and Number2Step 2 − Assign values to Number1 and Number2Step 3 − Use tuple syntax to swap −(Number1, Number2) = (Number2, Number1)Step 4 − Display the value ... Read More
4K+ Views
This tutorial will discuss how to write a swift program to add two numbers.Adding two numbers in Swift language is simple and can be performed with the help of the addition arithmetic operator(+). The arithmetic addition operator (+) uses two numbers as operands and returns their sum as output.In this operator, both the operands should be of the same data types, For example swift allows adding a float into float without an issue but if we will try to add different types of data types using (+) operator then the compiler will raise an error, For example adding an Int ... Read More
969 Views
This tutorial will discuss how to write a swift program toprint a string. A string is a collection of characters such as “TutorialsPoint”, “Hello Purnima! How are you?”, etc. Strings can also be represented by Unicode. We can easily create and modifies a strings because they are lightweight and readable, also we can do string interpolation. Strings can be used to insert variable, constants expressions, etc.SyntaxFollowing is the syntax for creating string type variableVar a : StringAlgorithm to print two stringsStep 1 − Define 2 VariablesStep 2 − Enter string into that variableStep 3 − Perform operations with that stringStep ... Read More
2K+ Views
This tutorial will discuss how to write a Swift program to find the perimeter of the circle.Perimeter of the circle is also known as the circumference of the circle. It is used to calculate the boundary of the circle. Suppose we want to fence our circular garden so with the help of perimeter we can calculate the total amount of fence required to cover the boundary of the garden. We can calculate the perimeter of the circle with the help of the radius or diameter, here, Radius − It is known as the distance from the center to a point ... Read More
3K+ Views
This tutorial will discuss how to write a swift program to find the area of square.A Square is a two-dimensional closed figure with four equal side and four equal angle. It can also have two diagonals of equal length. The area of the square is known as the space that is enclosed inside the boundaries of the square. Suppose we have a square study table now the area of the square helps us to find how much cloth we required to cover the top of the table. The area of the square is the product of its two side.FormulaFollowing is ... Read More
258 Views
Given a number in the form of a string, we need to find where to make it divisible by eight after deleting zero or more elements. In other words, we need to find whether there is a subsequence of the string, which is divisible by 8. Return the modified string or -1 if it is not possible.Any number whose last three digits are divisible by 8 is also divisible by 8. For example, 56992992 and 476360 are divisible by 8, but 2587788 is not. If the result is a whole number, then the original number is divisible by 8.We can ... Read More
241 Views
In this problem, we have a binary tree with a path from the root node to the leaf node that is completely defined. The sum of all nodes from a root node to a leaf node must be greater than or equal to k. So we need to remove all nodes in the paths whose sum is less than k. An important thing to remember here is that a node may be a part of many paths, so only remove such nodes if all the paths have sum < k.From the root node to the leaf node, we can calculate ... Read More
274 Views
In this article, we will learn how we can use multithreading in Ruby. We will take a couple of examples, where we will spawn two new threads and then perform some concurrent operations on them. In Ruby, we can create a new thread with the help of the Thread.new() function.Example 1Take a look at the following example to understand the nature of multiple threads and how they are executed in Ruby.#!/usr/bin/ruby # first method def First_Method a = 0 while a
423 Views
Ruby's integer class is the foundation for the two concrete classes that represent whole numbers. Bignum and Fixnum are these concrete classes. Bignum holds the integer value that is outside the range of Fixnum, which is displayed in the native machine word.There are a variety of methods in the integer class that can be used to perform various tasks. Numeric class has a subclass called Integer. Let's check some of the useful methods that are available in the integer class in Ruby.to_i methodThe to_i method is used to return an integer. Consider the code shown belowExampleConsider the code shown below.num ... Read More
1K+ Views
In Ruby, there are four different types of variables that we can declare −Local VariablesInstance VariablesClass VariablesGlobal VariablesAn Instance variable has a name that starts with the @ symbol. It should be noted that the contents of an instance variable are only restricted to the object which itself refers to.An important point to note about the instance variable in Ruby is that, even if we have two separate objects that belong to the same class, we are allowed to have different values for their instance variables.Instance Variable Characteristics in RubyBefore checking how to use instance variables in Ruby, let's understand ... Read More