Explanation :
If n=6 then output will be
* * * * * *
* * * * *
* * * *
* * *
* *
* .
Code:
import java.util.Scanner;public class StarPattern3
{
public static void main( String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter the no. of lines: ");
int line=sc.nextInt();
int i,j,k,t=0;
for (i=line; i>=1; i--)
{
for (j=1; j<=i; j++)
{
System.out.printf(" * ");
}
System.out.printf("\n");
}
}
}
No comments:
Post a Comment