Object Oriented Programming Articles - Page 79 of 915

Java Program to Print Hollow Right Triangle Star Pattern

AmitDiwan
Updated on 25-Feb-2022 13:33:52

5K+ Views

In this article, we will understand how to print hollow right triangle star pattern. The pattern is formed by using multiple for-loops and print statements. For the pyramid at the first line it will print one star, and at the last line it will print n number of stars. For other lines it will print exactly two stars at the start and end of the line, and there will be some blank spaces between these two starts.Below is a demonstration of the same −InputSuppose our input is −Enter the size : 8OutputThe desired output would be −The hollow pyramid triangle ... Read More

Java Program to Create Pyramid and Pattern

Alshifa Hasnain
Updated on 06-Jun-2025 14:37:45

4K+ Views

In this article, we will learn to create pyramid patterns using Java. It will help us to understand how loops work.  for loop while loop Java program to create pyramid patterns We are going to print the following pyramid patterns:  Half Star Pyramid Inverted Half Star Pyramid Star Pyramid Inverted Star Pyramid Numeric Pyramid Pattern 1: Half Star Pyramid We will initialize the row to 5 and a loop runs from i-1 to i

Print Pyramid Star Pattern in Java Program

AmitDiwan
Updated on 25-Feb-2022 12:38:05

6K+ 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 : * * * * * * * * * * * * * * * * * * * * * * * ... Read More

Java Program to Print Square Star Pattern

AmitDiwan
Updated on 31-May-2024 17:40:27

12K+ Views

In this article, we will understand how to print square 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 length of a side : 8OutputThe desired output would be −The square pattern : * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ... Read More

Java program to print diamond star pattern

Alshifa Hasnain
Updated on 13-Sep-2024 10:20:16

1K+ Views

In this article, we will understand how to print the Diamond Star pattern using Java. The pattern is formed by using multiple for-loops and print statements. Output Below is the demonstration of the diamond star pattern − The diamond star pattern : * *** ***** ******* ********* *********** ************* *************** ************* *********** ********* ******* ***** ... Read More

Java program to print star Pascal\'s triangle

AmitDiwan
Updated on 09-Sep-2024 01:19:20

735 Views

In this article, we will understand how to print star Pascal’s triangle in Java. 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. Problem Statement Write a program in Java to print star Pascal's triangle. Below is a demonstration of the same − ... Read More

Java program to print downward triangle star pattern

Manisha Chand
Updated on 22-Aug-2025 15:31:15

905 Views

In this article, we will understand how to print a downward triangle star pattern using Java. In this pattern, the face of the triangle will be in a downward direction, and the base will be in an upward direction. We will learn through two examples: one where the user inputs the number of rows, and another where the number of rows is predefined in the program. Problem Statement Write a Java program to print a downward triangle star pattern. Below is a demonstration of the same. Input: Enter the number of rows : 8 Output: The downward triangle star pattern ... Read More

Java Program to Print Mirror Upper Star Triangle Pattern

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

502 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

Alshifa Hasnain
Updated on 07-Jan-2025 18:56:02

1K+ Views

In this article, we will learn to print the upper star triangle pattern in Java. Printing patterns is a common exercise to strengthen the understanding of loops in programming. One of the most popular patterns is the Upper Star Triangle, which visually resembles an inverted right-angled triangle of stars aligned from the top. Below is a demonstration of the same − Input Enter the number of rows : 8 Output The upper star triangle star pattern : * ... Read More

Java Program to Print Pyramid Star Pattern

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

761 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

Advertisements