Computer Science, asked by mkmnahidbanu18, 1 month ago

Write a program in java to print this pattern​

Attachments:

Answers

Answered by anindyaadhikari13
5

Solution.

The given problem is solved using - Java.

public class Pattern{

   public static void main(String s[]){

       int n=6,i,j;

       for(i=1;i<=2 * n-1;i++){

           if(i<=n){

               for(j=n;j>=i;j--)

                   System.out.print("* ");

               System.out.println();

           }

           else{

               for(j=1;j<=i-n+1;j++)

                   System.out.print("* ");

               System.out.println();

           }

       }

   }

}

Output.

* * * * * *  

* * * * *  

* * * *  

* * *  

* *  

*  

* *  

* * *  

* * * *  

* * * * *  

* * * * * *  

See attachment for verification.

[tex][/tex]

Attachments:
Answered by kamalrajatjoshi94
0

Answer:

Program:-

public class Main

{

public static void main(String args[])

{

System.out.println("The pattern:");

for(int i=1;i<=5;i++)

{

for(int j=6;j>=i;j--)

{

System.out.print("*"+" ");

}

System.out.println();

}

for(int i=1;i<=6;i++)

{

for(int j=1;j<=i;j++)

{

System.out.print("*"+" ");

}

System.out.println();

}

}

}

Attachments:
Similar questions