Computer Science, asked by prashisharma, 5 hours ago

Using nested loops write program to generate the following pattern on the screen:​

Attachments:

Answers

Answered by anindyaadhikari13
3

Solution.

Assuming that the language is Java, the co‎‎‎‎de goes like -

public class Pattern{

   public static void main(String s[]){

       int rows=6,i,j;

       for(i=0;i<rows;i++){

           for(j=0;j<i;j++)

               System.out.print(" ");

           for(j=rows-i;j>=1;j--)

               System.out.print(j);

           for(j=2;j<=rows-i;j++)

               System.out.print(j);

           System.out.println();

       }

   }

}

Output.

65432123456

 543212345

   4321234

     32123

       212

         1

See the attachment for verification.

Attachments:

anindyaadhikari13: Thanks for the brainliest ^_^
Answered by kamalrajatjoshi94
0

Answer:

Program:-

public class Main

{

public static void main(String args[])

{

int c=6,d=6,e=0;

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

{

for(int p=0;p<=e;p++)

System.out.print(" ");

for(int j=c;j>=2;j--)

System.out.print(j);

for(int k=1;k<=d;k++)

System.out.print(k);

System.out.println();

c--;

d--;

e++;

}

}

}

Output is attached.

Attachments:
Similar questions