public class Pyramid2
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value ");
int n = sc.nextInt();
for (int i = 0; i < n; i++)
{
for (int spc = n - i; spc > 0; spc--)
{
System.out.print(" ");
}
for (int j = 0; j <= i; j++)
{
System.out.print("@");
}
System.out.println();
}
}
}
Output:
Enter the value
6
@
@@
@@@
@@@@
@@@@@
@@@@@@
BUILD SUCCESSFUL (total time: 2 seconds)
|
No comments:
Post a Comment