public class pat28 {
public static void main(String[] args) {
Scanner sc =new Scanner(System.in);
System.out.println("Enter The Row Of Pyramid:");
int n=sc.nextInt();
int i,j,k;
for(i=1;i<=n;i++)//row
{
for(j=1;j<=n*2-1;j++)//column
{
if((j>=n-(i-1))&&(j<=n+(i-1)))
{
System.out.print((char)(96+i));
}
else
{
System.out.print(" ");
}
}
System.out.println("");
}
}
}
This pattern program is a fantastic way to understand loops and formatting in Java! If you’re looking to dive deeper into Java programming, be sure to check out AmbitionHost for helpful resources.
ReplyDelete