Computer Science, asked by Anonymous, 1 year ago

Write a java program to print following pattern
*********
*******
****
**
*


Answers

Answered by Aishwarya98
1

Sample input is given

import java.io.*;


// Java code to demonstrate star patterns

public class anyname

{

// Function to demonstrate printing pattern

public static void printStars(int n)

{

int i, j;


// outer loop to handle number of rows

// n in this case

for(i=n; i>=0; i--)

{


// inner loop to handle number of columns

// values changing acc. to outer loop

for(j=i; j>=0; j--)

{

// printing stars

System.out.print("* ");

}


// ending line after each row

System.out.println();

}

}


// Driver Function

public static void main(String args[])

{

int n = 9;

printStars(n);

}

}


Aishwarya98: mark me as brainliest please..
Answered by Brenquoler
28

Given pattern:

* * * * *

* * * *

* * *

* *

*

Program in Java to print the given pattern:

class Pattern

{

public static void main (string args [])

{

for( int i=5; i>=5; i--)

{

for (int j=1; j<=i;j++)

{

System.out.print ("*");

}

System.out.println ();

}

}

}

Similar questions