Computer Science, asked by Anushkasampa123, 1 year ago

Do this program:)

*
**
***
****
***
**
*
☆In Java ☆

Answers

Answered by siddhartharao77
16
public class Basic
{
public static void main(String[] args)
{
int num = 5

int count = num - 1;

for(int k = 1; i <= num; k++)
{
for(int i = 1; i<= count; i++)

System.out.println(" ");

count--;

for(int i = 1; i<= k - 1; i++)

System.out.println("*");

System.out.println();
}

count = 1;

for(int k = 1; k <= num - 1; k++)
{

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

System.out.println(" ");

count++;

for(int j = 1; j <= (num - k) - 1; j++)

System.out.println("*");

System.out.println();
}
}
}



Hope this helps!

Answered by anindyaadhikari13
3

Question:-

Write a program to display the following pattern.

*

**

***

****

***

**

*

Code:-

class Pattern

{

public static void main(String s[])

{

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

{

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

System.out.print("* ");

System.out.println();

}

for(int i=3;i>=1;i--)

{

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

System.out.print("* ");

System.out.println();

}

}// end of main()

}// end of class

Similar questions