Found 33676 Articles for Programming

Find Scalar Multiplication of a Matrix in Java?

Mr. Satyabrata
Updated on 06-Mar-2023 11:23:01

717 Views

In Java, Array is an object. It is a non-primitive data type which stores values of similar data type. The matrix in java is nothing but a multi-dimensional array which represents multiple rows and columns. Scalar multiplication is nothing but multiplication between a matrix and a real number. The result of this multiplication is in matrix format. As per the problem statement, we have to find the scalar multiplication of a matrix. Let’s deep dive into this article, to know how it can be done by using Java programming language. To show you some instances Instance-1 Suppose the original matrix ... Read More

Find index of 0 or Any Negative Integer Element Present in Array in Java

Mr. Satyabrata
Updated on 06-Mar-2023 11:16:29

788 Views

As per the problem statement, we have given an array with some random integer values and we have to find out and print the index which contains any zero or negative values. Note - Take an integer array Let’s deep dive into this article, to know how it can be done by using Java programming language. To show you some instances Instance-1 Given Array= [1, 2, -3, -4, 0, 5] The index contains Zero and negative values = 2, 3, 4 Instance-2 Given Array= [-1, 0, 4, 6, 8, -5] The index contains Zero and negative values = 0, 1, ... Read More

Find Array Elements Which are Greater than its Left Elements in Java?

Mr. Satyabrata
Updated on 01-Mar-2023 12:24:32

495 Views

An array is a linear data structure in which elements are stored in contiguous memory locations. As per the problem statement, we have given an array with some random integer values and we have to find out the numbers which are greater than its all left elements by using Java programming language. Let’s start! To show you some instances Instance-1 Given Array= [1, 2, -3, -4, 0, 5]. The numbers which are greater than its all left elements = 2, 5 Instance-2 Given Array= [-1, 0, 4, 6, 8, -5]. The numbers which are greater than its all left ... Read More

Swift Program to get the subarray from an array using a specified range of indices

Ankita Saini
Updated on 19-Jul-2023 14:14:13

2K+ Views

In swift, we have various methods like Array() initializer and for-in loop that can be used for getting the subarray from an array using a specified range of indices. An array stores elements of the same data type in an order. Let’s understand both the methods in detail in this article. Method 1: Using Array() initialiser To get the subarray from an array using a specified range of indices we uses Array() initialiser. Here we find the subarray using range operator and then convert the elements into the array using Array() initialiser. Algorithm Step 1 − Create an ... Read More

Find Array Elements Which are Greater Than Its Immediate Left Element?

Mr. Satyabrata
Updated on 01-Mar-2023 11:42:26

1K+ Views

As per the problem statement, we have an array with some random integer values and we need to find out the numbers which are greater than its immediate left element. Note - Take an integer array. Let’s deep dive into this article, to know how it can be done by using Java programming language. To show you some instances Instance-1 Given Array= [1, 2, -3, -4, 0, 5]. The numbers which are greater than its left element = 2, 0, 5 Instance-2 Given Array= [-1, 0, 4, 6, 8, -5]. The numbers which are greater than its left element = ... Read More

Swift Program to get the flattened 1D array

Ankita Saini
Updated on 19-Jul-2023 14:19:52

632 Views

Swift has various functions like flatmap(), compactmap(), reduce() to flatten an 1D 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. Method 1: Using flatmap() Function To flatten 2D array into 1D array we can use flatmap() function. The flatmap() function return an array by concatenating the sub arrays into a single array. Syntax func flatMap{_res} Here, res is a closure which accepts the element of the specified array as its argument and return a flattened ... Read More

Find All Possible Coordinates of a Parallelogram in Java?

Mr. Satyabrata
Updated on 01-Mar-2023 11:40:21

386 Views

A parallelogram refers to the quadrilateral which has two pairs of parallel sides where opposite sides are equal in length, and the opposite angles are equal in measure. In this article we are going to find all possible coordinates of a Parallelogram. Basically, we will find all the possible coordinates from the given three coordinates to make a parallelogram of a non-zero area. Here the three given coordinates are not fixed points and can change. Therefore, if three coordinates are given, we may claim that there are only three coordinates from which we can build a parallelogram. As per ... Read More

Swift Program to convert an array into a string and join elements with a specified character

Ankita Saini
Updated on 19-Jul-2023 14:21:19

557 Views

In this article, we will learn how to write a swift program to convert an array into a string and join elements with a specified character. An array is used to store elements of same data type in an order. Here we use the following methods to join elements of the array with a specified character − Using joined(separator:) function Without using inbuilt function Method 1: Using joined(separator:) Function So to convert an array into a string and join elements with a specified character we use joined(separator:) method. This method is used to concatenate the elements of the ... Read More

Swift Program to Check if a String is Numeric

Ankita Saini
Updated on 19-Jul-2023 14:22:07

2K+ Views

To check if the given string is numeric or not we use Double() initializer in Swift Programming. A string is an ordered collection of characters for example “Sky”. A string can be numeric and non-numeric. A numeric string is a string which only contains numbers for example “12345”. So the valid numeric strings are: “3423”, “222333”, “34.342”, etc., whereas non-valid numeric strings are “23hfd23”, “423131sdd”, etc. So it converts the given string into double and return true if the given string is numeric otherwise return false. Algorithm Step 1 − Create a function Step 2 − Return ... Read More

Swift Program to calculate the sum of right diagonal of the matrix

Ankita Saini
Updated on 19-Jul-2023 14:23:32

319 Views

A matrix is an arrangement of numbers in rows and columns. A matrix has two diagonals i.e. Right diagonal and Left diagonal. So here we calculate the sum of the right diagonal of the square matrix using Swift Programming. For example, we have the following matrix − Matrix = 3 4 5 5 3 2 1 8 1 The right diagonal elements are 5, 3, 1. So the sum of right diagonal is 9(5+3+1). Algorithm Step 1 − ... Read More

Advertisements