Thursday, 18 February 2016

Print star pattern in java | Print star triangle in java

Print star pattern in java

Here i will show you how to print star pattern in java in java programming same concept are apply to write this code only you need to change C or C++ syntax.

Java Program to Print star pattern

Pattern 

            *
          ***
        *****
      *******
     *********
   ***********
  *************
***************

public class StarPattern
{
public static void main(String[] args)
{
for(int i = 10; i > 0; i--)
{
for(int j=1;j<i+1;j++)
{
System.out.print("*");
}
System.out.println();
}
}
}

Java Program to Print Star Pattern

*
**
***
****
*****
class StarPattern
{
public static void main(String[] args)
{
int j, i;
for (row = 1; j<= 10; j++)
{
fori= 1; i<= j; i++)
{
System.out.print("*");
}
System.out.println();
}
}
}

No comments:

Post a Comment