Found 9321 Articles for Object Oriented Programming

Java Program to Print Diamond Star Pattern

AmitDiwan
Updated on 25-Feb-2022 12:23:35

748 Views

In this article, we will understand how to print Diamond Star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The diamond star pattern :     *     ***   *****   *******   *********   ***********  ************* ***************  *************   ***********   *********   *******    *****     ***       *AlgorithmStep ... Read More

Java Program to Print Star Pascal's Triangle

AmitDiwan
Updated on 25-Feb-2022 11:58:52

517 Views

In this article, we will understand how to print star Pascal’s triangle. The Pascal’s triangle is formed by using multiple for-loops and print statements. All values outside the triangle are considered zero (0). The first row is 0 1 0 whereas only 1 acquire a space in Pascal’s triangle, 0s are invisible. The second row is acquired by adding (0+1) and (1+0). The output is sandwiched between two zeroes. The process continues till the required level is achieved.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows in Pascal's Triangle : 8OutputThe desired output ... Read More

Java Program to Print Mirror Lower Star Triangle Pattern

AmitDiwan
Updated on 25-Feb-2022 11:27:09

400 Views

In this article, we will understand how to print mirror lower star triangle pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The mirror lower star triangle pattern : * * * * * * * *  * * * * * * *   * * * * * *    * * * * *     * * * *      * * *       * *       ... Read More

Java Program to Print Downward Triangle Star Pattern

AmitDiwan
Updated on 25-Feb-2022 11:18:21

569 Views

In this article, we will understand how to print downward triangle star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The downward triangle star pattern : * * * * * * * * * * * * * * *  * * * * * *   * * * * *    * * * *     * * *      * *     *AlgorithmStep 1 - START ... Read More

Java Program to Print Mirror Upper Star Triangle Pattern

AmitDiwan
Updated on 25-Feb-2022 11:10:15

369 Views

In this article, we will understand how to print mirror upper star triangle pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The mirror upper star pattern : ******** ******* ****** ***** **** *** ** *AlgorithmStep 1 - START Step 2 - Declare four integer values namely i, ... Read More

Java Program to Print Upper Star Triangle Pattern

AmitDiwan
Updated on 25-Feb-2022 11:05:15

674 Views

In this article, we will understand how to print upper star triangle pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The upper star triangle star pattern :               *             * *           * * *         * * * *       * * * * *     * * * * * * ... Read More

Java Program to Print Pyramid Star Pattern

AmitDiwan
Updated on 22-Feb-2022 13:19:45

555 Views

In this article, we will understand how to print pyramid star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The pyramid star pattern :        *       * *      * * *     * * * *    * * * * *   * * * * * *  * * * * * * * * * * * * * * *AlgorithmStep 1 - ... Read More

Java Program to Print the Left Triangle Star Pattern

AmitDiwan
Updated on 22-Feb-2022 12:32:38

632 Views

In this article, we will understand how to print left triangle star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −The right triangle star pattern : * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *AlgorithmStep 1 - START Step 2 - Declare three integer values namely i, j ... Read More

Java Program to Print Left Triangle Star Pattern

AmitDiwan
Updated on 22-Feb-2022 12:24:23

617 Views

In this article, we will understand how to print left triangle star pattern. The pattern is formed by using multiple for-loops and print statements.Below is a demonstration of the same −InputSuppose our input is −Enter the number of rows : 8OutputThe desired output would be −* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *AlgorithmStep 1 - START Step 2 - Declare three integer values namely i, j and my_input Step 3 - Read ... Read More

Java Program to Check Whether a Number is Prime or Not

AmitDiwan
Updated on 14-Jun-2024 16:43:40

10K+ Views

Prime numbers are special numbers with only two factors 1 and that number itself, they cannot be divided by any other number. Therefore, to check whether a given number is prime or not, first, we will divide the given number by all natural numbers less than or equal to it and then, we check the number of factors. If the count of factors is only two then, the given number is prime otherwise not. This way of checking prime numbers is called as factorization. Now, let's understand how we can identify if a given number is prime or not by ... Read More

Advertisements