Found 33676 Articles for Programming

How To Check Whether a Number Is a Pronic Number or Not in Java?

Vivek Verma
Updated on 29-May-2025 15:19:37

7K+ Views

What is Pronic number? In mathematical terms, a Pronic number is a number that can be defined as the product of two consecutive integers. The Pronic number is in the form of n(n+1), where n is the integer. For example, the pronic numbers are 0, 2, 6, 12, 20, and so on. It is also known asa heteromecic number, oblong number, or rectangular number. Input & Output Scenarios Following are the scenarios that show the mathematical calculation for checking of the pronic number: Scenario 1 Suppose we have a number 12: Input: 12 Output: 4 x 3 = ... Read More

How To Check If Three Points are Collinear in Java?

Vivek Verma
Updated on 29-May-2025 15:16:06

2K+ Views

In mathematical terms, three points are said to be collinear if all three points lie on a straight line. If the points do not lie on the same straight line, then they are not considered collinear points. Those three points represent coordinates on a plane: (x1, y1), (x2, y2), and (x3, y3). They must lie on the same straight line to be considered collinear. Where, x1, y1, x2, y2, x3, y3 are the points on x and y axis and (x1, y1), (x2, y2), (x3, y3) are the coordinates.Determining Colinearity Mathematically, there are two ways to know whether the three points ... Read More

How To Check if a Triangle is Valid or Not When Sides are Given in Java?

Vivek Verma
Updated on 27-May-2025 13:37:32

9K+ Views

A Triangle is a polygon that has 3 sides, and it consists of three sides and three vertices. The sum of the three internal angles is up to 180 degrees. Below is the diagram of a triangle having three sides (a, b, and c): In a valid triangle, if you add any two sides, then it will be greater than the third side. As per our problem statement, we have to check if a triangle is valid or not, if three sides are given, using the Java programming language. Suppose a, b and c are the three sides of ... Read More

How To Calculate Volume of Prism in Java?

Vivek Verma
Updated on 26-May-2025 19:09:12

1K+ Views

A Prism refers to a three-dimensional solid object which has two identical ends. A prism has two faces, which are: Top and Bottom face. Lateral face Both top and bottom faces are called bases which are identical to each other. All lateral faces are also identical to each other which belong to the class of parallelograms. When the base of the prism is triangular in shape that prism is called a Triangular prism. Similarly, when the base of a prism is rectangular in shape it is called a Rectangular prism. ... Read More

Haskell program to read numbers from standard input

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 06:06:02

2K+ Views

In this tutorial, we discuss writing a program to get input from the user in the Haskell programming language. Haskell is a Declarative, Strongly Typed, and Functional programming language. This tutorial discusses reading numbers from standard input in the Haskell Programming language. Haskell is a purely functional Language. Pure functions are the ones that return the same output for the same arguments. Taking user input changes the program’s nature to impure. Haskell introduced a type IO that differentiates impure functions from pure functions. A function declaration with type IO infers that it is an impure function that interacts with the outer ... Read More

Haskell program to get input from the user

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 06:02:32

5K+ Views

In this tutorial, we discuss writing a program to get input from the user in the Haskell programming language. Haskell is a Declarative, Strongly Typed, and Functional programming language. Computations in Haskell are mathematical functions. In this tutorial, we discuss two ways to get input from the user in Haskell. User input using the getLine method. User input using the getChar method. As Haskell is a purely functional Language. Pure functions are the functions that return the same output for the same arguments. Taking user input changes the program’s nature to impure. Haskell introduced a type IO that ... Read More

Haskell program to add two complex numbers

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:59:49

884 Views

This tutorial will discuss writing a program to add two complex numbers in the Haskell Programming Language. Haskell is a declarative, strongly typed, and functional programming language. The computations in Haskell are mathematical functions. Complex numbers are a combination of real and imaginary values. Example: 1 + 2i, where i is √-1 In this tutorial, we see four ways to Add two complex numbers. Computing the addition using the infix operator for addition “+”. Implementing addition computation in a separate function. Computing the addition using the infix operator “+” as a function. Computing the addition of complex numbers by ... Read More

Haskell program to display alphabets (A-Z) using a loop

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:54:09

675 Views

This tutorial will discuss writing a program to display characters from A-Z in Haskell programming Language. Haskell is a Functional, Declarative, and Strongly Typed Language. The computations in Haskell are mathematical functions. In this tutorial, We see two ways to display Alphabets in Haskell. An iterative Program to display Alphabets. A recursive Program to display Alphabets. Note − Haskell doesn’t support Loops, So we mimic the function of a loop with other iterative and recursive implementations. Algorithmic Steps Implement the logic for printing Alphabets. Print/display Alphabets. Displaying Alphabets In An Iterative Way Using List Comprehensions. Example Program ... Read More

Haskell program to find the gcd of two numbers

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:52:39

2K+ Views

This tutorial will discuss writing a program to find the LCM of two numbers in the Haskell Programming Language. Haskell is a functional programming language. The GCD of two numbers is the Greatest Common Divisor/ Number that divides both numbers Can also be called as Highest Common Factor. In this tutorial, we discuss five ways to implement a program to find the GCD of two numbers. Using the inbuilt function gcd. Using the inbuilt function lcm. Computing GCD using list comprehension. Computing GCD using a recursive function with three arguments. Computing GCD using a recursive function with two arguments. ... Read More

Haskell program to find lcm of two numbers

Potti Chandra Sekhar sai
Updated on 27-Oct-2022 05:40:05

500 Views

This tutorial will discuss writing a program to find the LCM of two numbers in the Haskell Programming Language. Haskell is a functional programming language. LCM of two numbers is the least common multiple for that two numbers i.e smallest number that is divided by both numbers. In this tutorial, we discuss five different ways to implement a program to find the LCM of two numbers. Using inbuilt function lcm. Computing LCM using list comprehension. Computing LCM using a recursive function. Computing LCM using the HCF (Highest Common Factor) function. Algorithm steps Take the two integers as ... Read More

Advertisements