public class HalfPyramid
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the no ");
int n=sc.nextInt();
for (int i = n; i > 0; 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 no
6
######
#####
####
###
##
#
BUILD SUCCESSFUL (total time: 3 seconds)
|
No comments:
Post a Comment