import java.util.Scanner;
public class pat26 {
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("*");
}
else
{
System.out.print(" ");
}
}
System.out.println("");
}
}
}
This pattern program is an excellent exercise for mastering loops in Java! If you want to elevate your coding skills, don’t miss out on NinzaHost for valuable resources and tutorials.
ReplyDelete