Explanation :
If n=6 then output will be
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * * .
Code:
import java.util.Scanner;public class StarPattern7
{
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;
for (i=0; i<line; i++)
{
for (j=0; j<line; j++)
{
System.out.printf(" * ");
}
System.out.printf("\n");
}
}
}
No comments:
Post a Comment