Found 33676 Articles for Programming

Find Largest & Smallest Element in Each Column of a Matrix in Java?

Mr. Satyabrata
Updated on 04-May-2023 13:54:27

1K+ 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. Here we have given a matrix which contains set of elements and as per the problem statement we have to find out the largest and smallest element in each column of that 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-1Given matrix = 21 22 23 24 25 26 27 28 29 ... Read More

Find Largest & Smallest Element in Primary and Secondary Diagonal of a Matrix in Java

Mr. Satyabrata
Updated on 04-May-2023 13:50:28

547 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. Here we have given a matrix which contains set of elements and as per the problem statement we have to find largest and smallest element in primary and secondary diagonal 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-1Given matrix = 21 22 23 24 25 26 27 28 29 ... Read More

Check if a Point Exists in Circle Sector in Java

Mr. Satyabrata
Updated on 04-May-2023 13:42:45

412 Views

A circle is a closed shape formed by tracing a point that moves in a plane such that its distance from a given point is constant. In this article we will check how to form the equation of circle from given radius and centre. We will be given a circle with point i.e (x, y), radius r and centre i.e (x1, y1). We need to form the equation of circle from given radius and centre. The equation of the circle is given by formula − $$\mathrm{(x\:-\:x1)^2\:+\:(y\:-\:y1)^2\:=\:r^2}$$ Where, (x, y) is a point. (x1, y1) is centre. And r ... Read More

Least Frequently Used (LFU) Implementation

Diksha Patro
Updated on 03-May-2023 16:27:38

507 Views

A memory cache is an element of software or hardware which holds frequently accessed data in a convenient location. A cache is used to improve system performance by reducing the amount of energy it requires to access data. The memory ability establishes how much data a cache can store. While the memory cache is full, some data must be evicted in order to provide a place for new data. Following this, there is the fact that the world is ending. The Least Frequently Used (LFU) cache storage replacement policy is one of these policies. Everything in an LFU cache has ... Read More

Lamport's Bakery Algorithm

Diksha Patro
Updated on 03-May-2023 15:49:18

2K+ Views

A synchronization method called Lamport's Bakery method addresses the critical section issue in parallel computing systems. When more than one process needs to utilize a shared resource at once but only one process can do so, this is known as the critical section problem. To avoid conflicts and guarantee the accuracy of the system, the challenge is to make sure that each process uses the resource in a way that is mutually exclusive. Pseudo code for Lamport's Bakery Algorithm Here the Pseudo code for Lamport’s Bakery Algorithm − Initialize an array, called choosing, of size N, where N is ... Read More

Golang program to return the values from the block

Akhil Sharma
Updated on 03-May-2023 13:04:56

197 Views

In this golang article, we will learn how to return the values from the block using external function, an anonymous function. A block is created using curly braces where the scope of variables remains inside the block and not outside of it. Example 1 In this Example, two values of x and y are added in the code block and z will be assigned the added value. Then, call the function getResult in which another x and y are added and assigned to z in the code block. package main import "fmt" func main() { ... Read More

Golang program to convert milliseconds to minutes and seconds

Akhil Sharma
Updated on 03-May-2023 13:03:39

2K+ Views

In this golang article, we will write Go language programs to convert milliseconds to minutes and seconds using various methods. Milliseconds are converted to minutes and seconds mathematically using different set of logics. Algorithm Step 1 − Import the required packages in the program Step 2 − Create a main function Step 3 − In the main take milliseconds value and convert it into minutes and seconds using different logics mathematically Step 4 − Then, print the output using Printf function from the fmt package Example 1 In this Example, we will take the milliseconds value. Then, the ... Read More

Golang program to create multiple BEGIN and END blocks

Akhil Sharma
Updated on 03-May-2023 13:02:46

139 Views

In this article, we will learn to write Go language programs that will create multiple BEGIN and END blocks using curly braces, “conditional statements”, as well as “external functions”. A block is created using curly braces, the scope of a variable remains inside the block and not outside it. Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and output. Step 2 − Create a main function Step 3 − In the main, create a first block by initializing ... Read More

Golang program to demonstrate BEGIN and END blocks

Akhil Sharma
Updated on 03-May-2023 13:01:43

217 Views

In this Go language article, we will write programs to demonstrate BEGIN and END blocks using sum of numbers, iteration and two variables. Blocks are used to group the statements where the variables described in the block can only be used in that scope and not outside it. They also help in code readability Algorithm Step 1 − Create a package main and declare fmt(format package) package in the program where main produces executable codes and fmt helps in formatting input and output. Step 2 − Create a main function and in this function create two begin and end ... Read More

Golang program to format time in AM-PM format

Akhil Sharma
Updated on 03-May-2023 13:01:03

1K+ Views

In Go language article, we will write programs to format time in AM-PM format using now and format package, as well as using now and format function with minutes and seconds. The current time can be obtained using Now function from the time package whereas we can format the time using Format function as we are going to use in this article. In this article we will use “now and format function” to get the formatted time in AM-PM format. Syntax funcNow() Time The Now() function is defined in time package. This function generates the current local time. To ... Read More

Advertisements