*
**
***
****
***
**
*
OUTPUT ABOVE
class pattern_star2
{
public static void pattern4(int no)
{
int n=1;
for (int i=1;i<=no;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print('*');
}
System.out.println( "");
}
for (int i=no;i>=1;i--)
{
for(int k=1;k<=i-1;k++)
{
System.out.print('*');
}
System.out.println( "");
}
}
}
**
***
****
***
**
*
OUTPUT ABOVE
PROGRAM BELOW
class pattern_star2
{
public static void pattern4(int no)
{
int n=1;
for (int i=1;i<=no;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print('*');
}
System.out.println( "");
}
for (int i=no;i>=1;i--)
{
for(int k=1;k<=i-1;k++)
{
System.out.print('*');
}
System.out.println( "");
}
}
}
No comments:
Post a Comment