Home » » Program to print following pattern

Program to print following pattern

Written By Basith on Sunday, February 24, 2013 | 10:41 PM






public class Stars{

public static void main(String args[]){

int c=1;
for(int i=1;i<=5;i++)
{
for(int j=i;j<5;j++)
{
System.out.print(" ");
}
for(int k=1;k<=c;k++)
{
if(k%2==0)
System.out.print(" ");
else
System.out.print("*");
}
System.out.println();
c+=2;
}
}
}

0 comments:

Post a Comment

Followers