Computer Science, asked by upadhyayaprerona, 3 months ago

Write a java program to print the following pattern using nested for loop.​

Attachments:

Answers

Answered by tejas9193
0

Answer:

\huge\boxed{\fcolorbox{lime}{yellow}{⭐Answer☆☺⤵࿐}}

Leaving out the somewhat ridiculous and sometimes shameful religious slant towards this question, you would think that the purpose of humans is to find ways to work cooperatively to maintain the earth and its resources so that all of us have clean water and air, comfortable housing and clothing, adequate healthcare, and equal opportunities for work and education, and amenities such as transportation, communication, entertainment, and recreation. We should be able to do all this without polluting or spoiling the earth, which is, of course, the mother of all of us.

Answered by anindyaadhikari13
1

Answer:

The given co‎de is written in Java.

public class Pattern    {

   public static void main(String args[])  {

       int i,j;

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

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

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

           System.out.println();

       }

   }

}

Logic:

  • Logic is very easy. There are two loops needed for this pattern.
  • Outer loop iterates in the range 1 to 5. When i = 1, inner loop iterates 5 times (1 to 5) and so it prints the value of 'i' i.e., 1 five times.
  • Similarly, when i =4 loop, inner loop iterates 4 times and displays 2 on the screen.
  • After displaying each row, a new line is added.

Refer to the attachment for output.

•••♪

Attachments:
Similar questions