Found 33676 Articles for Programming

Swift Program to calculate the area of Cube

Ankita Saini
Updated on 25-Aug-2022 07:32:58

324 Views

This tutorial will discuss how to write a Swift program to find the area of the cube. A cube is solid three dimensional shape with six square faces and all the sides of the cube are of equal length(that means Length = Breadth = Width). It is also known as regular hexahedron.The area of a cube is known as the total space enclosed inside the boundaries of the cube. The area of cube is of two types- Total surface area Lateral surface area Total Surface Area The total area occupied by all the six faces of the cube ... Read More

How To Add Lifecycle Methods To a Class In ReactJS?

Huda Sameer
Updated on 23-Aug-2022 08:49:34

277 Views

Every component in React has a lifecycle that incorporates several phases. Programmers usually think of this lifecycle as the component’s ‘lifetime’. The components experience the following events: Mounting, Updating, Unmounting, and Error handling. Mounting refers to the procedure of adding nodes and updating requires programmers to alter and change these nodes in the DOM. Unmounting, on the other hand, removes nodes and error handling tracks your code to ensure it works and is bug-free. These occurrences can be compared to a component's birth, development, and eventual demise. You can override multiple lifecycle methods in each React lifecycle phase to execute ... Read More

How do I embed JavaScript expressions into JSX?

Geetu Magoo
Updated on 23-Aug-2022 08:39:05

822 Views

JSX is an extension used to easily create templates in ReactJS, a prominent framework of Javascript. Similar to how Javascript files are saved under the extension .js, React files are saved under the extension. jsx. With JSX, programmers can write HTML code in React and easily render the elements in the React DOM without needing additional methods or functions. What's more? JSX was created with the intention of easily converting HTML elements into React elements. In fact, JSX is beneficial for all sorts of programmers due to the fact that it’s faster than conventional Javascript. Developers can also design UI ... Read More

Swift Program to Find Sum of Even Fibonacci Terms Till number N

Ankita Saini
Updated on 19-Aug-2022 10:02:42

1K+ Views

This tutorial will discuss how to write a Swift program to find sum of even fibonacci terms till number N. A series of numbers in which every number is the sum of the two preceding numbers is known as Fibonacci series. The starting number of the Fibonacci series is 0 and 1, so the series is − 0, 1, 1, 2, 3, 5, 8, 13, 21, …… A number that is multiple of two is known as the even number. Or in other words, a number that is completely divisible by two is known as even number. For example, 2, ... Read More

Swift Program to Find LCM of two Numbers

Ankita Saini
Updated on 18-Aug-2022 13:24:57

903 Views

This tutorial will discuss how to write a Swift program to find LCM of two numbers. LCM is also known as Least Common Multiple. It is used to calculate the smallest common multiple between two or more numbers. Here common multiple represents a number which is multiple of two or numbers. For example, we have two numbers 10 and 8 Factor of 10 = 2 x 5 Factor of 8 = 2 x 2 x 2 Union of both factors = 2 x 2 x 2 x 5 = 40 So the LCM of 10 and 8 is 40. This ... Read More

Swift Program to Find GCD of two Numbers

Ankita Saini
Updated on 18-Aug-2022 13:20:37

1K+ Views

This tutorial will discuss how to write a Swift program to find GCD of two numbers. GCD is also known as Greatest Common Divisor or HCF(Highest common factor). GCD of two positive number is defined as the greater positive number which is the common factor of both the given two positive numbers. The value of GCD cannot be 0 or negative. The minimum value of GCD of two numbers is always 1. For example, we have two numbers 24 and 30. Factor of 24 = 2 x 2 x 2 x 3 Factor of 30 = 2 x 3 x ... Read More

Swift Program to Round a Number to n Decimal Places

Ankita Saini
Updated on 18-Aug-2022 13:14:28

6K+ Views

This tutorial will discuss how to write a Swift program to round a number to n decimal places. Rounding a number means round a decimal number to a certain number of decimal places or we can say round to the nearest wholes, tenths, hundredths, or thousandth. It save time and helps to express long term into short term. Rounding is only applicable on Float and Double data types. When you round a number always remember the following points − If the last digit is less than 5(that is 0, 1, 2, 3, 4) then round the previous digit down. For ... Read More

Swift Program to Sort Elements in Lexicographical Order (Dictionary Order)

Ankita Saini
Updated on 18-Aug-2022 13:07:44

644 Views

This tutorial will discuss how to write a Swift program to sort elements in lexicographical order(Dictionary order). An arrangement of the words, characters or numbers in alphabetical order staring from A to Z is known as lexicographic order. It is also known as dictionary order because the searching of the words are same as we search in the real dictionary. In lexicographical order, the words whose first letter is same are arranged in the same group and in the group words are sorted according to their second letter and so on. To sort the given list of elements into lexicographic ... Read More

Swift Program to Count the Number of Vowels and Consonants in a Sentence

Ankita Saini
Updated on 18-Aug-2022 13:01:24

1K+ Views

This tutorial will discuss how to write a Swift program to count the number of vowels and consonants in a sentence. An alphabet contains 26 letters out of which 5 are vowels and 21 are consonants. A, E, I, O, and U are known as vowels and B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Y, Z are known as consonants. Below is a demonstration of the same − Input Suppose our given input is − Entered String I like momos Output The desired output would be − ... Read More

Swift Program to Compute Quotient and Remainder

Ankita Saini
Updated on 18-Aug-2022 12:49:37

774 Views

This tutorial will discuss how to write a Swift program to compute quotient and remainder. In a division process, a number is divided by another number to get a resultant number. Or we can say that division is a process in which we divides larger number of group into small number of groups such that each group contain same number of elements. The four main terms of division are − Dividend − Dividend is a number which we divide. Divisor − Divisor is a number by which we divide Quotient − Quotient is the result obtained by the division. Remainder ... Read More

Advertisements