0% found this document useful (0 votes)
11 views

Reverse Star Pattern

Uploaded by

hanukumar2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Reverse Star Pattern

Uploaded by

hanukumar2007
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

// Java program to Print Reverse Pyramid Star Pattern

// Using While loop

// Importing input output classes


import java.io.*;

// Main class
class GFG {

// Main driver method


public static void main(String[] args)
{
// Declaring and initializing variable to
// Size of the pyramid
int number = 7;

int i = number, j;

// Nested while loops


// Outer loop

// Till condition holds true


while (i > 0) {
j = 0;

// Inner loop
// Condition check
while (j++ < number - i) {
// Print whitespaces
System.out.print(" ");
}

j = 0;

// Inner loop
// Condition check
while (j++ < (i * 2) - 1) {
// Print star
System.out.print("*");
}

// By now, we reach end of execution for one row


// so next line
System.out.println();

// Decrementing counter because we want to print


// reverse of pyramid
i--;
}
}
}

You might also like